Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Capture argument string

67 views
Skip to first unread message

Jim

unread,
Mar 25, 2013, 6:42:43 PM3/25/13
to
Is there a simple way to capture the entire argument string passed to
a VBScript? I don't need to parse or do anything with individual
arguments... I just need to pass the whole thing along, including
double-quotes so that the number of arguments doesn't change and so
that spaces within the arguments are preserved.

If I use something like the following, double-quotes are stripped.

For Each a In WScript.Arguments
args = args & a & " "
Next
WScript.Echo args

So that

>my.vbs "a 1" b "c 3"

spits out

a 1 b c 3


Dave "Crash" Dummy

unread,
Mar 25, 2013, 9:32:52 PM3/25/13
to
If you want to preserve the quotes around arguments that contain spaces,
this will work.

For Each a In WScript.Arguments
if instr(a," ") then a=chr(34) & a & chr(34)
args = args & a & " "
Next
WScript.Echo args

Or if you just want to insert non space delimiters between arguments
for n=0 to wscript.arguments.count -2
args = args & wscript.arguments(n) & ";"
Next
args=args & wscript.arguments(n)
WScript.Echo args

--
Crash

I'm smart enough to admit my ignorance.
0 new messages