Home

DOS

Why learn DOS?

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

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

Pipes ¦


¦     [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.

Redirects >

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

Append Redirect >>

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

Create a log-in script and run from the Windows registry.

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.

  1. First create a folder named log in the boot drives root ( C:\log )
  2. We turned off 'simple file sharing' in the folder options advance settings so we could set permissions on the folder.
  3. We right clicked the log folder and set the User rights to full control.
  4. We need to ensure that 'Hide extensions for known file types' is disabled in folder options advance settings. This is so we can rename our text file with the .bat file extension.
  5. We created our log file in Notepad and saved as C:\Windows\login.bat (note the path)
  6. Finally we ran regedit and created a new string value in HKLM\Software\Microsoft\Windows\CurrentVersion\Run named login.
  7. We then modified its value to the path of our login.bat file C:\Windows\login.bat

Some prompting questions

Further reading

Nice DOS guide

How to make DOS menus An old guide.

Sample Batch Files

The New Windows Power Shell (Thanks Ken)