如何使用参数调用Run()

Jou*_*uda 12 parameters vbscript batch-file

我在Windows Batch中有这个有效的代码行

start "" /wait /i "C:\Program Files\Sandboxie\Start.exe" /box:NetBeans /wait "C:\Program Files\NetBeans 7.3\bin\netbeans64.exe"
Run Code Online (Sandbox Code Playgroud)

我想通过VBScript运行它.但我不知道如何在内部有空格的参数中传递路径.

我提出了这样的事情:

Set objShell = CreateObject("Wscript.Shell")
objShell.Run("C:\Program Files\Sandboxie\Start.exe" /box:NetBeans /wait "C:\Program Files\NetBeans 7.3\bin\netbeans64.exe"), 1, True
Run Code Online (Sandbox Code Playgroud)

但是有一个错误:

预期:')'

小智 19

在文字字符串中,单个双引号字符由两个双引号字符表示.所以请尝试以下方法:

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run """C:\Program Files\Sandboxie\Start.exe"" /box:NetBeans /wait ""C:\Program Files\NetBeans 7.3\bin\netbeans64.exe""", 1, True
Set objShell = Nothing
Run Code Online (Sandbox Code Playgroud)


小智 5

我喜欢使用以下系统嵌入引号:

strCommand = Quotes("C:\Program Files\Sandboxie\Start.exe") & _
         " /box:NetBeans /wait " &                            _
         Quotes("C:\Program Files\NetBeans 7.3\bin\netbeans64.exe")

Function Quotes(ByVal strValue)
    Quotes = Chr(34) & strValue & Chr(34)
End Function
Run Code Online (Sandbox Code Playgroud)

它阅读起来容易得多.