Problems like this are more easily solved, if you approach them systematically:
Option Explicit
Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
Function qq(s) : qq = """" & s & """" : End Function
' Trying to identify the parts from the question
' """CMD /C python
' c:\filepath\python.py"" " &
' -i strPathAndFile & ""
' "-o c:\output_folder\ &"""
' Collect the parts
Dim sShell : sShell = "%comspec%"
Dim sPython : sPython = "python.exe" ' c:\Python25\python.exe, which("python2")
Dim sScript : sScript = goFS.GetAbsolutePathName(".\38081192.py")
Dim sInp : sInp = "d:\some\w h e r e\in.txt"
Dim sOut : sOut = goFS.BuildPath("z:\bitbucket", "out.txt")
' Combine them into a line by adding options and quotes **systematically**
Dim sCmd : sCmd = Join(Array( _
sShell _
, "/K" _
, qq(sPython) _
, qq(sScript) _
, "-i", qq(sInp) _
, "-o", qq(sOut) _
, "etc" _
))
WScript.Echo ">" & sCmd & "<"
output:
cscript 38081192.vbs
>%comspec% /K "python.exe" "E:\trials\SoTrials\answers\37990815\vbs\38081192.py" -i "d:\some\w h e r e\in.txt" -o "z:\bitbucket\out.txt" etc<
Printing the sCmd before you .Run it helps. And
nRet = oShell.Run(sCmd, 0, True)
is much easier to check.
cf. here, here, and here
On second thought:
After some experiments I learned that the python executable should not be quoted. So
, qq(sPython) _
to
, sPython _