12

I've got this working line of code in Windows Batch

start "" /wait /i "C:\Program Files\Sandboxie\Start.exe" /box:NetBeans /wait "C:\Program Files\NetBeans 7.3\bin\netbeans64.exe"

I would like to run it via VBScript. But I don't know how to pass the path in parameter which has a space inside.

I came up with something like this:

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

But there is an error:

expected: ')'

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Joudicek Jouda
  • 792
  • 2
  • 13
  • 30
  • Check stack overflow, they may know. There is also a way to call to copy ini files after the exe runs too. Vb is very neat. – MDT Guy Feb 22 '13 at 03:09

2 Answers2

19

Within a literal string, a single double-quote character is represented by two double-quote characters. So try the following instead:

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
5

I like to use the following system to embed quotes :

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

It's a lot easier to read.

db-user
  • 51
  • 1
  • 1