Using command line arguments in VBscript

Sunil picture Sunil · Mar 18, 2010 · Viewed 140.1k times · Source

How can I pass and access command line arguments in VBscript?

Answer

aphoria picture aphoria · Mar 18, 2010
Set args = Wscript.Arguments

For Each arg In args
  Wscript.Echo arg
Next

From a command prompt, run the script like this:

CSCRIPT MyScript.vbs 1 2 A B "Arg with spaces"

Will give results like this:

1
2
A
B
Arg with spaces