I am trying to pass a snipit of code as a command line argument to a program running on WinXP.
I have not been able to pass the entire code snipit as one argument.
It gets split by SPACE and QUOTE characters (as expected).
Quoting the whole thing and escaping QUOTE chars with QUOTE, SLASH or CARAT also fails…
Const TheCode = "main(""Literal String Argument"", 123, true)"
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.Run """c:\Folder with space\ArgTest.vbs"" """ & TheCode & """"
I run the following vbs script to echo the arguments back to test what is recieved.
ArgTest.vbs:
Dim ArgumentIndex
For ArgumentIndex = 0 to Wscript.Arguments.Count - 1
Call Msgbox(Wscript.Arguments(ArgumentIndex), vbOKOnly+vbInformation, "Argument " & ArgumentIndex)
Next
Edit:
It turns out that it is the VBS Echo script that stips out the QUOTES. Use QUOTE to escape.
There is no standard in Windows for escaping quotes. It is entirely up to the discretion of the developer of the app how quotes should be escaped. If you don’t have documentation for your app that explains how to do it, then you will have to discover it on your own (assuming the app even supports escaped quotes)
It sounds like you tried back slash:
You also say you tried caret:
Have you tried doubling up the quotes?