Reputation: 861
I have this code that I need to run a subprocess with and print off the output of whats in the command window.
import subprocess
msprompt = 'C:\Windows\Microsoft.NET\Framework64\\v4.0.30319\\MSBuild.exe'
path = "C:/Users/bgb/Documents/Brent/Code/Visual Studio/tree.DataManagement.UnitTests./tree.DataManagement.UnitTests.vbproj"
def command(msprompt, openFile):
for line in finalPathList:
p = subprocess.Popen([msprompt, path], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
print line,
retval = p.wait()
When I run this in the compiler it doesnt work, it spits out this message:
MSBUILD : error MSB1009: Project file does not exist.
Switch: "C:/Users/bgb/Documents/Brent/Code/Visual Studio/tree.FormControls.UnitTests./tree.FormControls.UnitTests.vbproj"
However, if I open up the command window completely seperate, and I copy over and paste msprompt
and then I copy over path
and paste it into the command window and hit enter, it works perfectly, does anyone know what I'm messing up in my command
function??
Help is greatly appreciated!
Upvotes: 0
Views: 483
Reputation:
I believe your path format is incorrect, it should be with two back slashes \\
and not forward slashes /
.
For debugging purposes, try using os.path.exists(path)
, to first make sure the path is correct. You can then use os.path.join
to fix your path (docs here).
Upvotes: 1