0

I am trying to run

compile_command = r'"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin\MSBuild.exe" "input/Applications/EPMD-Software/IpProtector/IpProtector.sln" /t:Rebuild /p:Configuration = Release /p:Platform = x64'
os.system(compile_command)

and getting

'C:/Program' is not recognized as an internal or external command, operable program or batch file.

How do I get windows to understand the string with spaces? Can't rename "program files" unfortunately...

Thanks

Gulzar
  • 23,452
  • 27
  • 113
  • 201
  • `c = r'''"C:\foo bar\New text document.bat"'''` works but I got the same error when using a single single quote for the raw string. Try triple single quotes instead of a single single quote for the raw string. – wwii May 21 '19 at 15:37
  • `r'"C:\foo bar\New text document.bat" a/b/d bah'` works and `r'''"C:\foo bar\New text document.bat" 'a/b/d' bah'''` works. Try removing the quotes from `"input/Applications/EPMD-Software/IpProtector/IpProtector.sln"` or triple quotes around the whole string and single quotes around `input/Applications/EPMD-Software/IpProtector/IpProtector.sln` – wwii May 21 '19 at 15:49
  • When doing both it seems to work. Thanks! Any explanation for this? – Gulzar May 21 '19 at 15:53
  • ..There are a number of hits with a search for `python windows execute string spaces` - probably a duplicate somewhere and maybe a `why`. – wwii May 21 '19 at 15:55
  • Now it complains about getting 2 projects as imput to the compiler. probably something to do with the options... is there a right way of doing this? – Gulzar May 21 '19 at 15:58
  • Sorry, don't know anything about `MSBuild.exe`. sounds like a different question. – wwii May 21 '19 at 16:01
  • running ' "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin\MSBuild.exe" "C:\code\EPMD\Installer\input\Applications\EPMD-Software\IpProtector\IpProtector.sln" "/t:Rebuild /p:Configuration=Release /p:Platform = x64" ' in cmd gives desired output. running `compile_command = r'''"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin\MSBuild.exe" "C:\code\EPMD\Installer\input\Applications\EPMD-Software\IpProtector\IpProtector.sln" "/t:Rebuild /p:Configuration=Release /p:Platform = x64"''' os.system(compile_command)` gives original prob – Gulzar May 21 '19 at 16:03
  • the duplicate question gives a strange permissions error – Gulzar May 21 '19 at 16:08
  • Works for me.... – wwii May 21 '19 at 16:15
  • from the duplicate's lower rated answers: `compile_command = r'""C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin\MSBuild.exe" "C:\code\EPMD\Installer\input\Applications\EPMD-Software\IpProtector\IpProtector.sln" "/t:Rebuild" "/p:Configuration=Release" "/p:Platform=x64""'` double quotes. I hate batch. – Gulzar May 21 '19 at 16:38

0 Answers0