for DOS, OS/2, Windows 95/98, NT 4, 2000 and XP
Technically, DOS provides just eight basic batch file commands — CALL, ECHO, FOR, GOTO, IF, PAUSE, REM, and SHIFT — plus a tiny assortment of miscellaneous doodads: replaceable parameters, environment variables, labels, double == signs, and @ signs. That's it! Not too much to learn, even for the most fervent DOS-hater. But the tools these few commands can create will astonish you.
The quickest way to learn the "doings" and syntax for each of the commands is too use MS-DOS's HELP program. Want to check out CALL? Type either
CALL /? or HELP CALL
at the prompt and DOS will display either a few lines of help (CALL /?) or open up its reference database (HELP CALL) with examples and usage syntax.
PC Computing - DOS Power Tools by Paul Somerson
Limited though it may seem to some, other people perform magic using DOS' batch language without "extensions".
Take a look at the tips and examples presented on these pages and in the links to other sites, and see for yourself that batch files are more powerful and versatile than you had ever thought possible.
Wherever "DOS" is referred to, MS-DOS 5 or any later version, including the COMMAND sessions of Windows NT and OS/2, is meant.
When "NT" is referred to, Windows NT 4 is meant, unless specifically stated otherwise. As far as I know most NT 4 commands work in Windows 2000.
Where Windows 2000 has some additional functionality, the added options will be shown in magenta.
When "OS/2" is referred to, OS/2 Warp 3 or later is meant.
Windows NT 4 / 2000 / XP users, you can use AllHelp.bat or AllHelp.vbs to generate a list of commands available in your operating system (and in the language of your OS), as is explained on my AllHelp page.
The main focus of this site will be on COMMAND.COM's and CMD.EXE's internal commands and on undocumented features and unusual use of features.
On magic, more or less.
I'm always open to new tips and suggestions.
If you see a DOS version mentioned as a minimum requirement, remember that I do not have access to every DOS version, so I cannot and did not test every feature in every DOS version.
If you do find an error here, or if you know of any useful "hidden feature" of any Intel based operating system that you would like to share, please send a message to
(DOS) commands and their usage in batch files
- Frequently Asked Questions (FAQ)
...plus, of course, some answers...
- Batch file How Tos
- Batch file examples in alphabetical order
- Search the batch file examples by function
- Solutions found on alt.msdos.batch
- More clever tricks
- Third Party batch files
- Useful commands for Windows administrators
- Ports of some UNIX shell commands to Rexx scripts and batch files
- The Poor Man's Administrator Tools (use native commands only)
- Terminal Server commands
- Short Command Line Tips ("Shorts")
- Undocumented commands
- Useless tips?
- Batch file related links
- Batch file utilities
- Debugging your batch files
- Using ANSI sequences to enhance batch files
- Using Arrays in batch files
- The AT scheduler
- Strange behavior of ATTRIB
- OS/2's AUTOFAIL command (a little off topic but very useful)
- How to use CHOICE
- Using CALL
- NT's COLOR command
- Command line parameters
- COMMAND.COM parameters, SHELL and COMSPEC
- Comments in batch files
- Conditional execution
- DATE and TIME
(Ab)using DEBUG in batch files
- DOS Devices
- DEVCON, Microsoft's command line device manager
- Tips on using DIR
- Windows Server 2003's Directory Service command line tools
- Batch generated e-mail
- ENDLOCAL (OS/2, Windows NT 4 and later)
- Display error messages in the local system language
- Escape characters
- EXIT batch code
- The FIND command
- Use FINDRAMD to find the RAM drive letter (Windows 9x)
- The FINDSTR command (Windows 2000 and later)
- Basic FOR loops in DOS
- FOR loops in NT
- FORMAT diskettes
- Unattended FTP
- GOTO, or: "How To Avoid 'Spaghetti Code'"
- IF statements
- Using the MEM command
- Notepad tips & tricks
- Abuse of the PATH command
- Generate popup messages
- Print files from the command line
- Control printers (Windows 2000)
- Managing Windows processes
- Using the PROMPT
- RAS and DUN (Dial-Up Networking)
- READLINE (internal command for OS/2's COMMAND.COM)
- How to read, add or modify Windows registry entries with REGEDIT
- RUNDLL and RUNDLL32
- XP's SCHTASKS command
- The SET command
- SETLOCAL (OS/2, Windows NT 4, Windows 2000)
- CONFIG.SYS' SHELL command
- Use SHIFT for command line parsing
Shutdown and reboot for several OSs
- Use START to start other programs from within a batch file (OS/2 and NT)
- Display a file's or directory's TRUENAME
- The TYPE command
- User input, or: "How To Make Your Batch Files Interactive"
- Mount and access VHD files as virtual disk drives with VHDMount
- WMI queries with WMIC
- NT's XCOPY
page last modified: 2016-09-19