Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
11Activity
0 of .
Results for:
No results containing your search query
P. 1
Batch File

Batch File

Ratings:

4.67

(3)
|Views: 3,106 |Likes:

More info:

Published by: paul_17oct@yahoo.co.in on May 28, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

12/15/2011

pdf

text

original

 
 A Modern Batch Programming Tutorial (Win 2k/XP)
Change the Look on This SiteThis page teaches you some modern NT-based batch programming and hassome fairly advanced and pretty useful batch scripts to help you get started.Batch files are the simple and rather archaic, interpreted scripting language of MS-DOS and it's derivatives and followers such as Windows 9x and NT (NT, 2k XP). Basic MS-DOS knowledge is assumed, and it does help if you know someprogramming language already, although this is not strictly necessary, I'll try toexplain most of the terminology on the way. I've written this in tutorial form sobe sure to check out other options and commands not covered here extensively. Although many of the commands and scripts represented here will work on MS-DOS and later, many Many of the newer command-options that are essential toadvanced batch programming do require Windows NT, 2000 or XP (of course2003 will also do as will probably LongHorn once it comes out). Although I didn't know it when I started writing this tutorial, I've later onrealized that the batch language is equivalent to the old late 70s basics havingcommands roughly equivalent to input, print, let, if and goto. And becauserepetition can be expressed with goto and if as in most assembler languages,you can build more elaborate programs out of these primitives. You may wonder why one would write batch files these days as there are reallygood, real programming languages around. Things like Perl, CPP or Java toname a few. For full blown programs I prefer Java or CPP , true, and Perl needsto be installed separately. Nowadays I tend to do all of these little programswith Perl and use batch files just on systems that don't have Perl installed. Butback to batches, I do find this an intellectual challenge, accomplishing as muchwith batches as is practical. Unlike Perl and many other languages, Batch filesare native to DOS and you can count on them on every machine without havingto download tens of megs of third-party software (well only about a floppy incase of tiny Perl). Batch syntax is also relatively easy and the language isinterpreted. OK there are Visual Basic script and JavaScript but I don't reallywant to learn either of those for various reasons including platform dependence.
WARNING:
While I've been working with DOS since MS-DOS 5 and still do use the DOS BOX
 
occasionally, it is still possible that some information in this document is not 100percent accurate, as I don't know the formal syntax of batch files exactly, nordo I know everything about DOS or NT specific batch commands. So, not to beused for mission critical stuff, hehe. Any comments, additions and correctionswould be welcome, though.
NOTE:
I tend to use the term NT to mean the set of operating systems based on theNT kernel (NT, 2000, XP and 2003 currently). In most cases it means Windows2000 or XP as most of the command-extensions were added in 2k, I believe.
Contents
Redirection
The Basics of Batch Programming
this section introduces the basic MS-DOS batch commands and concepts likerelative paths, redirection, pipes and variables (but some Windows pitfalls arealso mentioned). If you are an experienced batch programmer, you might want
 
to skip this section if you feel like it. However, if you've done batches but yourbatch knowledge is a bit rusty, for instance, acquired in the good old DOS days,you may wish to quickly browse through this in case there's anything new. Letme emphasize that I'm not trying to be complete and cover all the options andidioms, just the most useful you'll likely use most of the time.
Batch Syntax and Somee Practical Notes
Batch files are series of MS-DOS commands typed in a file, one command perline. The file uses the MS-DOS character set, has an extension of .bat and it isrun automatically if you type it's base name without the extension. If an exe orcom file with the same basename exists, you might want to explicitly specify the.bat extension to guarantee that the batch file gets executed. If you need to usehigh-ASCII characters in the file such as umlauts and special graphics symbols,you must save it as MS-DOS text otherwise the characters might be differentfrom what you expected. Many of the better Windows text editors can save asMS-DOS text (even Wordpad can), and there's good old Edit which still writesout MS-DOS files.The philosophy of batch programming is that nearly all of the batch constructsare ordinary commands that can also be used outside batch scripts in MS-DOS. Although some of these commands are virtually never used outside batches,they are still their in DOS. So most of the commands you'll be likely using areordinary DOS commands and work just as you would expect them to.By the way, if you run into problems in a batch file (e.g. it doing unwantedthings, getting stuck in a loop etc...) you can in most cases quit the execution of a batch file by pressing ctrl+c and answering y when asked if you really want toterminate the batch job.To get a list of all MS-DOS commands type in help in the prompt. For help on anindividual command type it's name followed by a slash and a question mark (e.g. copy /?). I recommend getting to know most of the commands that look interesting, so you'll be familiar with the set of tools used in real world batchscripting.In order for help to work in Windows 9X, you need todownload this set of oldDOS commands, extract it and run help in the current directory.One excellent resource covering pretty much everything from ancient DOS

Activity (11)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Hari Prasad liked this
Rodrigo Ogirdor liked this
rockandice liked this
HOGCALLER liked this
mykencarnado liked this
josele80 liked this
Chris Peterson liked this
fooshnagle7506 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->