Search code examples
bashmsysgitcmd

Bash calling cmd /c %ProgramFiles(x86)%\


From a bash script (bash from msysgit), I'd like to run MS VB 2010 Express compilation but none of the following lines works:

$ $PROGRAMFILES/Microsoft\ Visual\ Studio\ 10.0\\Common7\\ide\\vbexpress.exe path/to/solution.sln /build

Results in sh.exe": C:\Program: No such file or directory

$ "$PROGRAMFILES/Microsoft\ Visual\ Studio\ 10.0\\Common7\\ide\\vbexpress.exe" path/to/solution.sln /build

Results in sh.exe": C:\Program Files (x86)/Microsoft\ Visual\ Studio\ 10.0\Common7\ide\vbexpress.exe: No such file or directory

$ cmd /c "$PROGRAMFILES(X86)/Microsoft\ Visual\ Studio\ 10.0\\Common7\\ide\\vbexpress.exe" path/to/solution.sln /build

This will open the cmd-shell only, as cmd seems not to recognize the argument to the parameter /c

$ cmd "/c $PROGRAMFILES(X86)/Microsoft\ Visual\ Studio\ 10.0\\Common7\\ide\\vbexpress.exe" path/to/solution.sln /build

Error Message: Command C:\Program" not found

$ /c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio\ 10.0/Common7/IDE/vbexpress.exe IOS\\IOS.sln /build

Kinda works, but though it starts VB Express it complains that C:\Program Files (x86)/Git/build could not be load - clearly the shell expands /build to a path. And this solution is flawed as I would like to use an environment variable to distinguish between 32-bit and 64-bit installations of Windows.

What's the correct way of escaping the path separators and space to get this working?


Solution

  • While I do not have this particular software, I believe that something like this works:

    "$PROGRAMFILES/Microsoft Visual Studio/10.0/Common7/IDE/vbexpress.exe" 'IOS\IOS.sln' '//build'
    

    I tried it to invoke some other software like:

    "$PROGRAMFILES/Internet Explorer/iexplore" 'T:\public_html\index.html'