Arguments - VBScript


The Arguments object provides access to command-line arguments passed to a VB Script. It is an indexed collection, with each element representing one argument.


Dim args As Arguments




Simple Usage

Dim x
x = Arguments(1)
WScript.Echo "The first argument is " & x

Looping Through Arguments

Dim x
For Each x In Arguments
    WScript.Echo x

Common Issues

Argument Index Out of Range

Make sure the argument index specified is within the range of valid arguments. Use the Arguments.Count property to determine the number of arguments available.


The Arguments object can be used in conjunction with other VB Script commands to process command-line inputs. For example:

Dim args As Arguments
Dim value As String
value = Left(args(1), 5)
WScript.Echo "The first 5 characters of the first argument are " & value
  • WScript.Arguments: Provides access to command-line arguments in a WSH environment.
  • CommandLine: An environment variable containing command-line arguments (not available in WScript).