繁体   English   中英

使用来自VBscript的参数调用Python脚本

[英]Calling Python script with arguments from VBscript

我有一个带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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM