Shell.Run with arguments

一笑奈何 提交于 2019-12-12 16:20:48

问题


I'm trying to run a program (with argument /config) using Shell.Run from VBS. However I'm having an exit code = 87 (cannot find the file specified).

1st piece of code I've tried:

strCommand = """c:\Program Files\Test\launch.exe""" & " /config:C:\sample.xml"
intExit = objShell.Run(strCommand, 0, True)

2nd piece of code:

Dim FileExe, Argum
FileExe = "%ProgramFiles%\Test\launch.exe"
Argum = "/config:C:\sample.xml"

RunMe FileExe, Argum

Function RunMe(FileExe, Argum)
    Dim Titre, ws, Command, Exec
    Titre = "Execution avec argument"
    Set ws = CreateObject("WScript.Shell")
    command = "cmd /c "& qq(FileExe) & " " & Argum &" "
    Msgbox command, 64, Titre
    Exec = ws.Run(command, 0, True)
End Function

Function qq(str)
    qq = chr(34)& str &chr(34)
End Function

来源:https://stackoverflow.com/questions/17566540/shell-run-with-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!