1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim lRet&
    lRet = Shell("cmd /k devenv m:\myproject.sln /build Release", 1)

End Sub

This fails with the command line saying "devenv" is misspelt or not found.

Does anybody know why?

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
tmighty
  • 10,734
  • 21
  • 104
  • 218
  • 3
    Is it on the `%PATH%` environment variable? – Oded Mar 29 '13 at 13:28
  • What do you mean, please? – tmighty Mar 29 '13 at 14:05
  • You can find path to devenv from registry using command `reg query`. – Vladimir Mar 29 '13 at 14:10
  • Look at file `c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat` for details. – Vladimir Mar 29 '13 at 14:11
  • Usually, path to devenv is not your %path% varialbe. So, cmd just does not know where to look for devenv.exe – Vladimir Mar 29 '13 at 14:12
  • I am using VS2010. I have also tried the following MsgBox(File.Exists("C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe")) Dim lRet& lRet = Shell("cmd /k C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe m:\myproject.sln /build Release", 1) but then the command line tells me that "c:\Program" was not found. Argh... – tmighty Mar 29 '13 at 14:14
  • @Validmir Frolov Do you mean the environment variable "Path"? If yes, I have added the path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\" to the environment variable "Path", but the command line still does not find it. – tmighty Mar 29 '13 at 14:15
  • "cmd /k \"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe\" m:\myproject.sln /build Release" – Vladimir Mar 29 '13 at 21:01
  • Path with spaces should be surrounded by double quotes. – Vladimir Mar 29 '13 at 21:02

1 Answers1

0

I ran all "bat" files that I could find in the VC programs directory. First I started them not as as admin, and it did not work. When I started the bats as an admin, the command would finally work. Also I had to move to the VS path using CD.

tmighty
  • 10,734
  • 21
  • 104
  • 218