Batch File

Last Edited



Batch File is an ASCII file with the extension .bat or .cmd containing a series of commands.

What is Batch File

Also called a batch program, an ASCII file with the extension .bat or .cmd containing a series of commands. These commands are executed sequentially when the batch file is invoked at the command prompt or in a logon script. Batch files are used primarily to simplify the execution of routine or repetitive administrative tasks such as mapping drives, synchronizing system clocks, or performing backups.

Batch File
Batch File

Batch files trace their origin to MS-DOS (the autoexec.bat file is the most well-known example), but they are still used by administrators for logon and installation scripts in Microsoft Windows NT and Windows 2000 and for other administrative purposes. With the advent of the Windows Script Host (WSH) – which is included in Windows 98, Windows 2000, and the Windows NT Option Pack and which allows administrative scripts to be written in higher-level scripting languages such as Microsoft Visual Basic Scripting Edition (VBScript) and JavaScript—the old batch file paradigm might finally be about to disappear.

Batch File example

If you want to control the rate at which directory information is replicated between a backup domain controller (BDC) and a primary domain controller (PDC) on a Windows NT–based network, you can create a batch file that will change the value of the ReplicationGovernor parameter on the BDC. First create a script that has the full path to this parameter in the registry along with the value you want to assign to it, and then create the following simple batch file:

regini <Script_Name>net stop netlogon
net start netlogon

Two different scripts and batch files can be created for different times of the day, and the at command can be used to schedule the execution of each batch file at the appropriate time. This illustration is especially useful if directory replication must occur over a slow WAN link, and it can be used to ensure that most replication traffic occurs during off hours.