Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Using parameters in batch files: %0 and %9</strong></p> <p>Batch files can refer to the words passed in as parameters with the tokens: <code>%0</code> to <code>%9</code>.</p> <pre><code>%0 is the program name as it was called. %1 is the first command line parameter %2 is the second command line parameter and so on till %9. </code></pre> <p>parameters passed in on the commandline must be alphanumeric characters and delimited by spaces. Since <code>%0</code> is the program name as it was called, in DOS <code>%0</code> will be empty for AUTOEXEC.BAT if started at boot time.</p> <p><strong>Example:</strong></p> <p>Put the following command in a batch file called <code>mybatch.bat</code>:</p> <pre><code>@echo off @echo hello %1 %2 pause </code></pre> <p>Invoking the batch file like this: <code>mybatch john billy</code> would output:</p> <pre><code>hello john billy </code></pre> <p><strong>Get more than 9 parameters for a batch file, use: %*</strong></p> <p>The Percent Star token <code>%*</code> means "the rest of the parameters". You can use a for loop to grab them, as defined here:</p> <p><a href="http://www.robvanderwoude.com/parameters.php">http://www.robvanderwoude.com/parameters.php</a></p> <p><strong>Notes about delimiters for batch parameters</strong></p> <p>Some characters in the command line parameters are ignored by batch files, depending on the DOS version, whether they are "escaped" or not, and often depending on their location in the command line:</p> <pre><code>commas (",") are replaced by spaces, unless they are part of a string in double quotes semicolons (";") are replaced by spaces, unless they are part of a string in double quotes "=" characters are sometimes replaced by spaces, not if they are part of a string in double quotes the first forward slash ("/") is replaced by a space only if it immediately follows the command, without a leading space multiple spaces are replaced by a single space, unless they are part of a string in double quotes tabs are replaced by a single space leading spaces before the first command line argument are ignored </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload