[英]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.