Although DOS appears to be an outdated operating system it is in fact what Windows is built upon. Learning how to handle the command line and understanding the directory structure is essential for the PC Technician. In Linux for example there are many things which can only be done from the command line, the same is true for Windows XP when it comes to managing networks.
On this page the ▲ symbol denotes a single sace and the ¬ symbol denotes the enter key.
Windows DOS | Linux BASH |
---|---|
The root = \ (Backslash) | The root = / (Forward Slash) |
Change Directory = cd | |
List = dir | List= ls |
Make a Directory = mkdir or md | Make a Directory = mkdir |
Copy = cp | |
Parent directory = cd.. | Parent directory = cd▲.. |
Both operating systems enable Tab Completion. - I.e. type part of the next path and press Tab to complete the name.
Both operating systems enable command history by pressing the up arrow cursor key.
Switches follow DOS commands and are used to customise the command. They are OPTIONAL. To see all available switches for a command use the special help switch /? e.g.
dir▲/? ¬ Some examples DIR▲/p ¬ Pauses each screen if the output is large DIR▲/s ¬ Recurses subdirectories I.E. searches in directories below the current directory. The next example includes an optional parameter *.dll DIR▲/s▲/p▲*.dll ¬ Finds all DLL files below the current directory and pauses each screen. chkdsk switches
¦ [Alt Gr] + [key to left of number 1] Pipes are used to automate input to other commands COMMAND OUTPUT ¦ COMMAND INPUT (Output PIPED to input of next command) ECHO▲y▲¦▲DEL▲A:\somefile.txt Gives the output of ECHO to the input of the DEL command so when the DEL command requires a y/n response the pipe automates the y response.
Output from DOS commands will default to the screen or con (short for console). This output can be redirected using the > command to other locations:
prn - locally connected DOS printer (E.G. dir▲/s▲*.dll▲>▲prn ) File Path - creates a new file at that location (E.G. dir▲/s▲*.dll▲>▲C:\MyDLLs.txt ) nul - used to suppress any output E.G. ECHO▲y▲¦▲DEL▲A:\somefile.txt▲>▲nul suppresses "1 file deleted" output
Similar to a redirect however used to append output to an existing file I.E. doesn't replace the existing file.
ipconfig▲>▲C:\NetStats.txt Creates the file with the output from the ipconfig command Followed by the append ping▲127.0.0.1▲>>▲C:\NetStats.txt Try it and view the results at C:\NetStats.txt
There were several steps - Here is the brief.
We want a batch file to execute each time someone logs in. The batch file, on first run, would create the log file and then on further logins it would append to the existing file. We needed to ensure all users could modify this log file i.e. Add an entry to the log.
Nice DOS guide
How to make DOS menus An old guide.
Sample Batch Files