SoFunction
Updated on 2025-04-12

autoit command line parameter description

Note that the script file name is not included in the parameters. If you want to obtain the script file name, please check the instructions about @ScriptName. If a parameter contains space characters, the parameter must be surrounded by "double quotes". The compiled script also receives command line parameters in the same way.

$CmdLine[0] saves the number of parameters in the command line (excluding script file name)
$CmdLine[1] is the 1st parameter
$CmdLine[2] is the second parameter
...
We often use $CmdLine[$CmdLine[0]] to represent the last parameter...

 

If your script is run like this:

myscript.au3 Parameter 1 "This is a string parameter"

$CmdLine[0] is equivalent to... 2

$CmdLine[1] is equivalent to... Parameter 1

$CmdLine[2] is equivalent to...This is a string parameter

@ScriptName equivalent to... myscript.au3

 

In addition to $CmdLine, there is also a variable called $CmdLineRaw, which saves the complete unsplit command line statement. For the example above

$CmdLineRaw is equivalent to...myscript.au3 Parameter 1 "This is a string parameter"