Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用VBscript中的参数调用Python脚本_Python_Vbscript - Fatal编程技术网

使用VBscript中的参数调用Python脚本

使用VBscript中的参数调用Python脚本,python,vbscript,Python,Vbscript,我有一个带有2个参数的Python脚本,我想通过VBscript运行它。问题是,当我在windows命令行中手动键入命令时,它可以正常工作。当我想从.vbs文件调用相同的脚本时,它不会运行.py文件。此时会出现一个新的命令窗口,并很快消失。.vbs中的脚本是: SET oShell = WScript.CreateObject("Wscript.Shell") currentCommand = "D:\xxxx\xxxxx.py aaaa bbbbbbb" WScript.echo curren

我有一个带有2个参数的Python脚本,我想通过VBscript运行它。问题是,当我在windows命令行中手动键入命令时,它可以正常工作。当我想从.vbs文件调用相同的脚本时,它不会运行.py文件。此时会出现一个新的命令窗口,并很快消失。.vbs中的脚本是:

SET oShell = WScript.CreateObject("Wscript.Shell")
currentCommand = "D:\xxxx\xxxxx.py aaaa bbbbbbb"
WScript.echo currentCommand
oShell.run currentCommand,1,True
将“python”添加到currentCommand时没有区别。 我也试过这样:

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
如何使用.vbs文件中的多个参数调用/运行.py文件

注意:当我在没有参数的情况下调用/运行另一个.py时,它工作正常

尝试将其更改为:

currentCommand = "cmd /c " & Chr(34) & source_code_path & " " & variable1 & " " & variable2 & Chr(34)

我的命令也起作用了。这部分是我的错误。谢谢