Q: VBScript howto split a quoted delimited AND spaced separate values? I have the following string:
"C:\Program Files\Application\Path\executable.exe" -- "/flag"
I am trying to split the string so that I get:
array(0) = C:\Program Files\Application\Path\executable.exe
I don't care about the rest of the array since I am just concerned about the file path not the args.

A: This will do it.
dim p : p = """C:\Program Files\Application\Path\executable.exe"" -- ""/flag"
dim r : r = mid(p,2,instr(2,p,"""")-2)


A: If you don't want to mess with Mid and InStr, you can make use of regular expressions. For example, this will retrieve the first quoted substring (without the outer quotes) from your string:
Dim strCommandLine, strPath, re

strCommandLine = """C:\Program Files\Application\Path\executable.exe"" -- ""/flag"""

Set re = New RegExp
re.Pattern = """(.*?)"""

strPath = re.Execute(strCommandLine)(0).SubMatches(0)

