Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


February 05, 2000

What commands can I use in a batch file?

RSS
Subscribe to Windows IT Pro | See More Windows NT 4.0 Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

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
...
:label1
...
if <condition> .. The if statement has a lot of functionality. Common uses include the following.
if /i <string1> <compare> <string2> <command> 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
if exist <file name>
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.

End of Article



Reader Comments
Ok,
but all this commands are just about Windows NT???
and if i have to execute logon batch files from
windows 95 workstations?

Rafael Pivato December 05, 2000


Rafael: Well it is a windows NT / 2000 FAQ, what did you expect?

Chris December 19, 2002


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,

Geo October 27, 2003


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

syedasadali April 14, 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

Jason Parker May 31, 2004


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



Anonymous User April 08, 2005 (Article Rating: )


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 May 06, 2005 (Article Rating: )


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...

2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...


Scripting Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement