Reputation: 55
I have a Python script with 2 arguments and I would like to run it via VBscript. The problem is when I type command manually in windows command line, it works without a problem. When I want to call the same script from a .vbs file, it doesn't run the .py file. A new command window appears and disappears quickly. The scripts in .vbs is :
SET oShell = WScript.CreateObject("Wscript.Shell")
currentCommand = "D:\xxxx\xxxxx.py aaaa bbbbbbb"
WScript.echo currentCommand
oShell.run currentCommand,1,True
There is no difference when add "python" to currentCommand. I also tried like this:
SET oShell = WScript.CreateObject("Wscript.Shell")
Dim source_code_path
source_code_path = "D:\xxxx\xxxxx.py"
Dim variable1
variable1 = "aaaa"
Dim variable2
variable2 = "bbbbbbb"
Dim currentCommand
currentCommand = source_code_path & " " & variable1 & " " & variable2
WScript.echo currentCommand
oShell.run currentCommand,1,True
How can I call/run .py file with several arguments from .vbs file?
Note : When I call/run another .py without argument, it is working fine.
Upvotes: 3
Views: 11333
Reputation: 35280
Try changing it to:
currentCommand = "cmd /c " & Chr(34) & source_code_path & " " & variable1 & " " & variable2 & Chr(34)
Upvotes: 3