DOS script demonstration

One of the advantages of a command-line user interface is that one can combine several commands into a single script (a short, interpreted program). In DOS, these files have the extension .bat (batch).

The following is a listing of whatisintemp.bat, a file with a 5 command script:

c: (switch to drive C) cd c:\temp (change to the directory c:\temp) dir (list the contents of the dirctory) echo that is all! (display "that is all!") f: (switch back to drive F) The comments in parenthisis are for clarification, and are not part of the batch file.

I put the file on a flash drive, drive F, opened a command window, switched to drive F, then typed the name of the file name (whatisintemp) to execute it. As you see here, the commands were executed in order. (I shortened the directory listing).

C:\USERS\LARRYP~1>f: F:\>whatisintemp F:\>c: C:\Users\LARRYP~1>cd c:\temp c:\temp>dir Volume in drive C is OS Volume Serial Number is 62AA-9AA9 Directory of c:\temp 10/08/2008 05:07 PM <DIR> . 10/08/2008 05:07 PM <DIR> .. 09/24/2008 10:55 PM 38,912 10 Questions_Larry Press2.doc ... 07/31/2008 11:36 PM 255 y_key_30c8ae4b2ac39436.html 94 File(s) 561,553,211 bytes 3 Dir(s) 29,799,301,120 bytes free c:\temp>echo that is all! that is all! c:\temp>f: F:\>

Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.