DOS Batch Programming
General Rules
General Rules
Named parameters are enclosed in percentage signs, as in %name% while input parameters are numeric and use only one percentage sign, as in %1.
WAIT
WAIT
In command prompt there is no direct support for timed wait command. However, there is Choice command that has a time parameter that indicates how long it should wait for selection. This can be used for timing.
In Windows 7 this can be done in the following way (in this example we wait for 5 seconds):
CHOICE /N /C Y /T 5 /D Y >NUL
Calling another batch file
Calling another batch file
call anotherfile.bat
Directories
Directories
Current Directory
Current Directory
%CD%
Changing Directories
Changing Directories
Use PUSHD/POPD to switch directories.
IF Command
IF Command
Example of conditional branching:
@ECHO OFF
:TOP
IF (%1)==() GOTO END
ECHO Value is "%1" and still running...
SHIFT
GOTO TOP
:END
See attached if.cmd.txt file for example.
Date and Time
Date and Time
See attached script.
Parameters
Parameters
References:
- parameters (link)
Links
Links