Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  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 log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

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

How can I stop and start services from the command line?

...

Microsoft Touts Xbox 360 'Black Friday' Success

Microsoft this week revealed that its Xbox 360 video game console outsold its Sony PlayStation 3 rival 3-to-1 on "Black Friday," which curiously describes the three day weekend after Thanksgiving, a period that unofficially kicks off the holiday selling ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events 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 Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


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 Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing