I am trying to use subprocess.run
with a custom argument, that works both directly from windows cmd, and from subprocess.call
, but not with subprocess.run
, as suggested by Running shell command and capturing the output.
This works:
retcode = subprocess.call(build_command_line, shell=True)
This fails:
result = subprocess.run([build_command_line], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
and outputs
The filename, directory name, or volume label syntax is incorrect.
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python37\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
File "C:\Program Files\JetBrains\PyCharm 2020.1.1\plugins\python\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 551, in new_CreateProcess
return getattr(_subprocess, original_name)(app_name, patch_arg_str_win(cmd_line), *args)
PermissionError: [WinError 5] Access is denied
even though I run with administrator.
Not that it should matter, but for completeness:
build_command_line
is:
'"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe" "C:\\code\\EPMD\\Kodex\\Solutions\\Kodex.All.sln" /t:REBUILD /p:Configuration=RELEASE'
How do I get it to work with subprocess.run
?