Network Administration: Batch Files - dummies

Network Administration: Batch Files

A batch file is simply a text file that contains one or more commands. Batch files are given the extension .bat and can be run from a command prompt as if they were commands or programs. You can also run a batch file from the Start menu by choosing Start→Run, typing the name of the batch file, and clicking OK.

As a network administrator, you’ll find plenty of uses for batch files. Most of them won’t be very complicated. Here are some examples of very simple batch files:

  • A one-line file was used to copy the entire contents of an important shared network drive to a user’s computer every night at 10 p.m. The user had just purchased a new Dell computer with a 100GB drive, and the server had only a 20GB drive. The user wanted a quick-and-dirty backup solution that would complement the regular tape backups that ran every night.

  • A pair of short batch files were used to stop and then restart Exchange server before and after nightly backups for backup software that didn’t have an Exchange plug-in that could back up the mail store while it was open.

  • If you frequently need to work with several related folders at once, a short batch file can be created that opens Explorer windows for each of the folders. (You can open an Explorer window from a batch file simply by typing the path to the folder that you want to open as a command.) Then, place the batch file on your desktop for quick access.

You can also use batch files to create logon scripts that are executed whenever a user logs on. Microsoft keeps trying to get users to use profiles instead of logon scripts, but many networks still use logon scripts.