Quick DOS Guide

Quick DOS Guide

DOS (Disk operating system) was at the heart of windows computers until recently. More recently it was hidden beneath the GUI we now think of as Windows. To run a DOS command via the command window: Start>Run at the prompt type cmd then enter. A command window should appear. It will be a window with gray text in a black background that will look familiar to anyone who worked with DOS based computers pre-Windows 95. From this window you can execute DOS command in an interact session. The command window you can issue DOS command to execute programs, copy or delete files and much more. Most of these commands have been wrapped in a GUI (what we now think of when we think of Windows) but are still accessible via the command window. DOS s equivalent in UNIX/Linux is a korn or bash shell however DOS lacks many of the data management tools out of the box that are standard with a Unix/Linux installation.

cd change directory
Type cd ~
Result ~ is your home directory.
dir gets a list of all files and directories in current directory. Type: dir
ResultMicrosoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\Users\Ted>dir
Volume in drive C has no label.
Volume Serial Number is xxxx-xxxx Directory of C:\Users\Ted 03/19/2008 07:47 PM <DIR> .
03/19/2008 07:47 PM <DIR> ..
01/28/2008 07:06 PM <DIR> Contacts
05/27/2008 05:16 PM <DIR> Desktop
05/07/2008 06:59 AM <DIR> Documents
05/07/2008 06:51 AM <DIR> Downloads
03/19/2008 07:47 PM 575,342 ElfPDFStream.pdf
04/15/2008 06:34 PM <DIR> Favorites
01/28/2008 07:06 PM <DIR> Links
05/09/2008 07:01 PM <DIR> Music
02/29/2008 04:42 PM <DIR> Pictures
01/30/2008 07:33 PM <DIR> Saved Games
01/28/2008 07:06 PM <DIR> Searches
01/28/2008 07:06 PM <DIR> Videos
2 File(s) 580,944 bytes
13 Dir(s) 138,648,293,376 bytes free
PIPING |   Pipe or redirect output to another command.  This allows you to chain multiple commands together without having to create files at each immediate step. >  Pipe or redirect output to a physical file. Type: dir > test.out    
Results: Now you have created a text file is the deletes of the file located
mkdir Make a directory. Type: mkdir test
Results: type ls and see your directory listed.
rename Moves or renames a file. This is useful to rename output files when debugging a process.
Type: rename test.out list.out
Results: now the file test.out has been renamed to list.out.
cp Copy a file or directory (with -r option).
Type cp list.out test.out
Results Now you have two file list.out and test.out
rmdir Removes a directory
del Remove a file .
Type rm list.out
Results the list.out file has been deleted.
type Allows read-only access to a file.  To quit out of MORE type :q.
Type: more test.out
Result: The output should look the same as if you ran the ls –l command.
edit Edit is a command line text editor for DOS that is similar to VI.
echo To make text appear in the command window use the echo command.  This can be useful to alert users to how a script or program is running.
Attrib The change the permissions or mode of a file use attrib.  Type attrib +r test.out

Clears command window of all text so far written back from the bat script

REM Use REM to put comments into the script
top List the top 10 processes on the machine.  Important to tell whether you are playing nice with others.
Use to set environmental variables.

  Set path =  

Run another bat from script without stopping .
Call c:\MyBatchTwo.bat
PAUSE Halts the execution of the code till user input. Useful to see error messages and output of the code.
Environmental Variables
Example Environmental Variables below.
%winDir%. Path to the windows directory.
%userprofile% Path to user s directory

%OS% The OS