【发布时间】:2014-06-26 15:05:28
【问题描述】:
我有一个带有 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
在 currentCommand 中添加“python”没有区别。 我也试过这样:
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 时,它工作正常。
【问题讨论】:
-
我的命令也有效。这部分是我的错误。谢谢。