3

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.

1
  • My commands are also working. It is partly my mistake. Thanks. Commented Jun 27, 2014 at 8:18

1 Answer 1

3

Try changing it to:

currentCommand = "cmd /c " & Chr(34) & source_code_path & " " & variable1 & " " & variable2 & Chr(34)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.