


Some characters in the command line 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:
#Kofax vrs creating batch name windows#
In Windows NT 4, 2000 and XP you can SHIFT the command line parameters starting from the nth positions using SHIFT's / n switch, where n can be any (integer) number between 0 and 8:

In that case, use IF = or, in NT 4 (SP6) and later only, IF "%~1"="" instead. IF "%1"="" will cause problems if %1 is enclosed in quotes itself. Use a loop to handle any number of command line parameters: OFF However, %10 does not equal J but A0 %10 is interpreted as %1, immediately followed by a 0.ĭoes that mean the rest of the parameters is lost?Īfter your batch file handled its first parameter(s) it could SHIFT them (just insert a line with only the command SHIFT), resulting in %1 getting the value B, %2 getting the value C, etcetera, till %9, which now gets the value J.Ĭontinue this process until at least %9 is empty. Now %1 equals A, %2 equals B, etcetera, until %9, which equals I. Let us assume your batchfile is called with the command line parameters A B C D E F G H I J K. The batch file's limitation to handle parameters up to %9 only can be overcome by using SHIFT. This means that, in AUTOEXEC.BAT, you can check if it is being started at boot time or from the command line, for example to prevent loading TSRs twice. Since %0 is the program name as it was called, in DOS %0 will be empty for AUTOEXEC.BAT if started at boot time. Read my SETLOCAL page if you intend to use SETLOCAL extension switches.īatch files can only handle parameters %0 to %9 Likewise, you may disable command extensions using SETLOCAL DISABLEEXTENSIONS or CMD /Y. However, to be absolutely sure that they are, either use SETLOCAL ENABLEEXTENSIONS within your NT shell scripts (batch files) or execute those scripts using CMD /X.
