Subscribe to Windows IT Pro
February 05, 2000 12:00 AM

What commands can I use in a batch file?

Windows IT Pro
InstantDoc ID #13438
Rating: (11)

A. Windows NT 4.0 introduced several extensions to cmd.exe. Use these extensions to ensure that the HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions registry entry is set to 1. The following table lists the most commonly used commands.

call <batch file> 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 <string> <filename(s)> Finds a string in a file. This powerful command has several parameters.
for Standard for loop. The command
for /L %n IN (1,1,10) DO @ECHO %n
Would print 1 to 10.
goto <label> Causes a program’s execution to skip to a given point. A colon must precede the label name. For example,
goto label1<br>
...<br>
:label1<br>
...
if <condition> .. The if statement has a lot of functionality. Common uses include the following.
if /i &lt;string1&gt; &lt;compare&gt; &lt;string2&gt; &lt;command&gt;
The /i parameter makes the comparison case-insensitive. The comparison can be one of the following.
EQU—equal
NEQ—not equal
LSS—less than
LEQ—less than or equal
GTR—greater than
GEQ—greater than or equal
if errorlevel<br>
if exist &lt;file name&gt;
rem <string> A comment.
start <window title> <command> Starts a new command session and runs a given command. Unlike with the call command, the current batch file’s execution continues.

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

Related Content:

ARTICLE TOOLS

Comments
  • Anonymous User
    7 years ago
    May 06, 2005

    Hi, can some one tell me how can % symbol be echo in batch program? for example: @echo off echo 1234% and the result would just 1234. Pls help

  • Anonymous User
    7 years ago
    Apr 08, 2005

    to perform an enter in a batch file you must first create a support file to accompany it and then use file input/output redirection using the '<' symbol:

    -enter.dat-
    [carriage return - just press your enter key once]
    save this file

    -yourapp.bat-
    'command' < enter.dat

  • Jason Parker
    8 years ago
    May 31, 2004

    http://www.winnetmag.com/Article/ArticleID/13438/13438.html
    On the above URL, it has a section -20 Most Read articles that covers the common command files and I am unable to clearly read. FYI to help others also. HTML issue

  • syedasadali
    8 years ago
    Apr 14, 2004

    please send me command of enter(how can i do enter in the batch file)

  • Geo
    9 years ago
    Oct 27, 2003

    I'd like to create a batch file but have the file launch programs in an ordely fashion. I don't want all the programs launching at the same time. I want them launching in the order I put them, but it's not working. This is what I have.

    @echo off
    start /wait /b C:\\Progra~1\\Outloo~1\\msimn.exe
    start /wait /b Z:\\WIN32\\nwadmn32.exe
    start /wait /b C:\\Novell\\WScont~1\\WScontrol.exe
    start /wait /b C:\\Progra~1\\Avaya\\SiteAd~1\\bin\\ASA.exe
    start /wait /b Z:\\mgmt\\Consol~1\\1.2\\bin\\Consol~1.exe
    start /wait /b http://advhelpdesk/scripts/pdmcgi.exe
    :end

    Please help.

    Thanks,

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.