What commands can I use in a batch file?

John Savill

February 4, 2000

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. Windows NT 4.0 introduced several extensions to cmd.exe. Use these extensions to ensure that the HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorEnableExtensions registry entry is set to 1.

Related: What commands can be used to configure the command window?

The following table lists the most commonly used commands.

call

Calls one batch file from inside another. The current batch file’s execution is suspended until the called batch file completes.

exit

Stops a batch file from running. If one batch file calls another, exit stops both batch files.

findstr

Finds a string in a file. This powerful command has several parameters.

for

Standard for loop. The command

Would print 1 to 10.

goto

Causes a program’s execution to skip to a given point. A colon must precede the label name. For example,

if ..

The if statement has a lot of functionality. Common uses include the following.

The /i parameter makes the comparison case-insensitive. The comparison can be one of the following.EQU—equalNEQ—not equalLSS—less thanLEQ—less than or equalGTR—greater thanGEQ—greater than or equal

rem

A comment.

start

Starts a new command session and runs a given command. Unlike with the call command, the current batch file’s execution continues.

Learn more: Resource Kit Batch File Commands

The Microsoft Windows NT Resource Kit includes some additional utilities that you might find useful.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like