But no matter how creative you get, MS-DOS batch remains just a list of commands. Imagine if you could use words like "if" to turn batch into a full-fledged programming language!

Well, such a wish is not just realistic, but it is also true. The following commands serve practically no purpose unless you're using batch:

CLS (Clear screen)
IF
SET
ECHO
REM
CALL
PAUSE
GOTO
CHOICE

Type each of those commands with "/?", and you're well on your way to knowing all the important stuff about batch.

Aside from that info, you should know that to use an environment variable (declared by "SET") you type it as thus: for the variable "var1" type %var1%. Anyplace in DOS where you could type a string, you can instead type a variable. E.g., "copy %file1% %file2%".

If a batch file is opened with parameters, e.g. "fun.bat Joe 12", you can access those parameters within the file by %1, %2, etc. In the example above, %1 in the batch file is a variable with the value of "Joe", and %2 has the value of "12". For more freedom, you can use the "SHIFT" command to delete %1 and shift everything else down one (%2 becomes %1, %3 becomes %2, etc.).

 

Proceed:   <-- Autoexec.bat       --> Quick Reference Guide
 

Back to the Hub