Printer Friendly
Dictionary, Encyclopedia and Thesaurus - The Free Dictionary
1,508,130,391 visitors served.
forum mailing list For webmasters
?
New: Language forums
Dictionary/
thesaurus
Medical
dictionary
Legal
dictionary
Financial
dictionary
Acronyms
 
Idioms
Encyclopedia
Wikipedia
encyclopedia
?

DOS batch file

   Also found in: Wikipedia, Hutchinson 0.07 sec.

DOS batch file

A file of DOS commands that are "batch" processed one after the other. Windows also supports batch files (see Windows batch file), which are mostly identical to the DOS commands.

To create a DOS batch file, use a text editor such as Edit. If you use a word processor, save your batch file as an ASCII text file, not as a standard document. Always include a .BAT extension with your batch file name.

The following batch file switches to the E drive, goes to the PAT directory and runs the MYPROG program:

         e:
         cd \pat
         myprog


If the file above was named PAT.BAT in the BATCH directory on drive C, you would execute it by typing:
        C:\BATCH>pat


Tip!
If you use batch files to launch applications such as in the example above, make a hard disk directory called BATCH or BAT and put all your batch files in it. Also make sure that the batch files directory is named in the Path command in your AUTOEXEC.BAT file (see DOS Path name) so that you can execute your batch files from whichever directory you're currently in; for example:
          C:\BATCH>pat
          D:\XYZ>pat
          E:\BUDGETS>pat


If you create a batch file that works with files in only one directory, then place the batch file in that directory. When you want to run it, go to that directory.

Stopping a Batch File
To stop a batch file in operation, press Ctrl-C or Ctrl-Break.

Quick Reference
The following commands are for quick reference only. If you are not an experienced batch file programmer, consult a good book on the subject, such as Kris Jamsa's "DOS Batch File Power" published by SAMS.

  cls        Clear the screen
  rem        Remarks
  ::         Remarks
  echo off   Turn off display
  @echo off  Turn off display (3.3 and up)
  echo on    Turn on display
  echo       Display message; for example,
              echo Press any key to continue.
  call       Call other batch file
  pause      Stop (wait for keystroke)
  choice     (DOS 6) a way to get user input

  if not exist filename goto :line
  if not string1==string2 goto :line
  if not errorlevel 0 goto :line
  for %%varname in (files) do command
  %0        - Batch file name
  %1 - %9   - Input variables
  %varname% - Variable used with Set

Following is an example of the choice batch file command in DOS 6. It loads three different programs depending on receiving A, B or C from the user. If A is entered, errorlevel is 1, B is 2 and C is 3. IF ERRORLEVEL always tests for >=, which is why the largest number is tested first.
   choice /c:abc  Run A.  Run B.  Run C.
   if errorlevel 3 goto runC
   if errorlevel 2 goto runB
   :runA
   run program A
   goto end
   :runB
   run program B
   goto end
   :runC
   run program C
   :end



How to thank TFD for its existence? Tell a friend about us, add a link to this page, add the site to iGoogle, or visit webmaster's page for free fun content.
?Page tools
Printer friendly
Cite / link
Email
Feedback
? Mentioned in ? References in periodicals archive
 
Used in conjunction with DOS batch files, this command can be even more effective.
Retrospect supports external scripts from DOS batch files to compiled applications created in C or Visual Basic, providing unlimited extensibility for advanced users.
Users no longer need to run a DOS batch file before using ReachOut under Windows.
 
Encyclopedia browser? ? Full browser
 
 
Encyclopedia
?

Disclaimer | Privacy policy | Feedback | Copyright © 2009 Farlex, Inc.
All content on this website, including dictionary, thesaurus, literature, geography, and other reference data is for informational purposes only. This information should not be considered complete, up to date, and is not intended to be used in place of a visit, consultation, or advice of a legal, medical, or any other professional. Terms of Use.