Using command line arguments in VBscript

Command LineVbscriptCommand Line-Arguments

Command Line Problem Overview


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

Command Line Solutions


Solution 1 - Command Line

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

Solution 2 - Command Line

If you need direct access:

WScript.Arguments.Item(0)
WScript.Arguments.Item(1)
...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSunilView Question on Stackoverflow
Solution 1 - Command LineaphoriaView Answer on Stackoverflow
Solution 2 - Command LineJertherView Answer on Stackoverflow