Windows 95 / DOS 7 Batch Programming
-- If you're a system administrator, you're probably here because
you need to schedule or accomplish a certain task. You typically have
four ways of accomplishing sysadmin tasks:
1 - Find a dedicated utility program that does your single task. I won't help you with this method.
2 - Write a batch file that accomplishes your task. This page serves as an introduction to the techniques most people need to solve moderately complex batch problems. Batch files are great for simple things, and the basics of batch programming are fairly easy to understand. Unfortunately, people who can write and maintain complex batch files are becoming hard to find. Batch files are also limited by the command-line environment they are trapped in.
3 - Write a script that accomplishes your task. I have a scripting web page that may be able to help you out a with scripts. Scripts can control most programs and controls you have on your system. Scripting can pretty much do anything. The down side of scripting's greater power is that it has a steeper learning curve.
4 - Get a system administration tool like Network Automation's AutoMate. Good tools don't come cheap, so home users with no budget should plan on learning to write scripts or batch files. Corporate users will find a GUI-driven admin tool like AutoMate to be pretty handy because sysadmins won't be needing as much programmer support. Managers will appreciate that a system administration tool makes it possible to fill (or back-fill) sysadmin positions with non-programmers.
Readme Where to get the "missing" DOS commands. Where to get help on DOS.
Sample Batch Files Maybe your problem has already been solved.
Getting User Input Seven different methods spanning DOS6 through Windows 2000 (and XP).
Creating Secondary Batch Files How to use a batch file to create another batch file or script as it is needed.
Processing a Line of Data The most widely-implemented method of processing lines involves getting the name of a batch file on the beginning of a line of data. This allows the data on the line to be passed as arguments to the batch file.
Processing Characters in a Word Once you know how to extract and work with the individual words in a line, you'll find yourself wanting to work with the individual letters in the words.
Processing Lists Assuming you know how to process individual lines, you have to find a way around DOS' annoying program flow. It never returns when you want it to. Here's how to keep DOS on task and process every line in a file.
Making and Processing Lists of File Names Actually just using the DIR command appropriately, then processing the result with the techniques shown above. But it is such a common question...
Stupid DOS Tricks These tricks aren't widely known and are almost never used. Usually because they never seem to apply to whatever it is you're working on at the moment.
NT Batch Programming Not a tutorial, just a listing of code fixes for NT when the techniques shown on this page won't work.
In my opinion, all these links point to pages that are as good as -- or better -- than what I offer. Suggestions for new links are always welcomed.
Simon Shepard's ss64.com NT Syntax
Batfiles: The DOS Batch File Programming Handbook & Tutorial
EasyDOS Command Index
Lost? Look at the site map.
Bad links? Questions? Send me mail.