为什么执行失败,说找不到路径?

时间:2017-09-20 10:15:01

标签: windows vbscript

为什么它无法使用API_SDK.exe传递的命令行参数执行cmd.vbs

enter image description here

> cmd.vbs "execute#abcd 1234/"

cmd.vbs:

result = WScript.Arguments.Item(0)
splits = Split(result, "#")
split_result = splits(1)
main_command = Replace(split_result, "/", "")

Set LoginScript = CreateObject("WScript.Shell")

strCurDir = LoginScript.CurrentDirectory
run_command = strCurDir & "\API_SDK.exe " & main_command

box = MsgBox(main_command, vbYesNo + vbInformation, "")
WScript.Echo run_command

' FAILING TO EXECUTE
LoginScript.Run run_command, 0, False

编辑:

' 1 - Spoon feed
Function Quotes(Byval strValue)
    Quotes = Chr (34) & strValue & Chr(34)
end Function 

' 2 - Command line argument / parser
result = WScript.Arguments.Item(0)
splits = split(result, "://")
split_result=splits(1)
main_command = Replace(split_result, "/", "")

' 3 - Prepare pathing 
Set LoginScript    = CreateObject("WScript.Shell")
'strCurDir = LoginScript.CurrentDirectory
run_command = "C:\Program Files (x86)\ABCD XYZ 1234\api_sdk.exe"


' 4 - Seeing is believing 
strCommand = Quotes(run_command) & " " & main_command
box=Msgbox(strCommand,vbYesNo+vbInformation, "")
WScript.Echo box

' 5 - Run that mother
LoginScript.Run strCommand, 0, False

0 个答案:

没有答案