Home Page 2
Index Next Page
DOS for Windows9x

Using DOS Commands

Topics
Commands DOS Commands & The PATH CD Changing Directory
LFNs Long File Names Switches About Switches
PRN Printing in DOS Wildcards Using Wildcards
F1-F3 The F1 & F3 Keys CLS Clearing the Screen
Doskey A Note on DOSKEY Main Topic Index
~ Topics and Commands listed in Green are an essential basis for DOS. ~
~ Those in Blue are less so, but are still useful. ~

DOS Commands & The PATH
A command is simply something you type at the Command Prompt and then press Enter to start it off. DOS under Win9x is mostly in the   C:\WINDOWS\COMMAND\   directory with some in   C:\WINDOWS\   In practice it does not matter which. (Previously it was all in   C:\DOS\).

DOS will look for the command to execute in the 'current directory' first. This applies as much to 'system' DOS commands as to DOS commands to run programs which will only run in DOS mode (some older games, for example).

Say the command you want to use is   golf.exe /s   and the Prompt is   C:\GAMES\TENNIS>   it will look in that directory first. If it fails to find it there, it will then look in the directories specified by the 'PATH' statement in your Autoexec.bat. The default under Win9x is:
       PATH C:\WINDOWS;C:\WINDOWS\COMMAND

So in this example, DOS will look for the command in C:\GAMES\TENNIS\   then   C:\WINDOWS\   then   C:\WINDOWS\COMMAND\

Since the command you want is not in one of these, you will need to change directory - see Changing Directory below - or type the full path (ie:   C:\GAMES\GOLF\GOLF /S  ).

When you type a command you can leave off the extension, but bear in mind that DOS will look for the file to run in the order: *.Exe files, *.Com files, *.Bat files. If there are two files in the folder DOS looks in with the same name, it will assume you mean the *.Exe version rather than the *.Com or *.Bat one. This is not normally a problem.

The DOS commands you are most likely to wish to use are in Essential Commands.   Further Commands includes more useful but not essential ones.   Do not worry if a command mentioned does not have its own *.Exe or *.Com file anywhere. Where this is the case it will be contained within the 'Command Interpreter' -   COMMAND.COM
Top of Page     Main Topic Index

Changing Directory
Unless you are issuing a command which runs a file in the current directory or the PATH directories, you must change to the Directory the command is in, or type the complete path to the file. To change you simply type   CD path  . For example, if the Prompt is   C:\>:
  • CD WINDOWS    changes the current directory to   C:\WINDOWS\
  • CD \WINDOWS\COMMAND    changes the current directory to   C:\WINDOWS\COMMAND\
    While you do not need to include the ' \ ' for a main directory you do need to specify it when changing to a sub-directory.
  • CD ...    changes 'up' two levels back to   C:\
  • CD ..    changes 'up' a level back to   C:\WINDOWS\
  • CD \    changes right back to the root directory   C:\
  • CD      simply shows you the 'current' directory
  • D:    changes from drive   C:   to drive   D:
    Note that you cannot simply enter   CD D:\DATA\DOCS   but must change to that Drive first and then enter   CD \DATA\DOCS.
    Commands in the PATH will still operate, regardless of what drive or directory you are in.
Top of Page     Main Topic Index

Long File Names (LFNs)
In DOS Mode:
You cannot use file names longer than the standard DOS '8.3' format. Start counting! If you want to specify a directory whose name is more than 8 characters, type the first 6 as normal omitting spaces but including underlines, then a Tilde  ( ~ )  then the number 1.
The same applies to the first part of a filename - only type the first 6 characters normally. Where the file extension is longer than 3 characters, only type the first 3.
Examples
Long NameBecomes
C:\PROGRAM FILES\ACCESSORIES\ C:\PROGR~1\ACCESS~1\
C:\MY DOCUMENTS\ C:\MYDOCU~1\
SEARCHING.HTMLSEARCH~1.HTM
hp_extranews_jun99_uk.htmHP_EXT~1.HTM
Lightning1.bmpLIGHTN~1.BMP
Lightning2.bmpLIGHTN~2.BMP
Lightning3a.bmpLIGHTN~3.BMP
Lightning3b.bmpLIGHTN~4.BMP
Letter to Mike.docLETTER~1.DOC
Letter to Bank.docLETTER~2.DOC

Yes, it does get tricky! For this reason it is often best to leave Directories and Files with LFNs alone in DOS Mode, in case any copying, renaming etc screws up the names. If you do copy, move or rename, check that all is correct as soon as possible from within Windows.

In A DOS Box:
If you are in a DOS Box and type   CD PROGR~1   the Prompt will change to   C:\Program Files\  - but try typing that in and you'll get   Invalid directory

You can get around this by using quotation marks, eg:   CD "Program Files"   or   CD "\Program Files\Accessories"   and all will be well. (The same applies to specifying LFNs).
Top of Page     Main Topic Index

Using Switches
The various letters, numbers, etc - often but not always with the forward-slash or oblique   ' / '   - typed after a DOS command are called Switches. They tell the command exactly what you want it to do. For example, in DOS mode type:   dir /?    [Enter]   and you will get a list of the available Switches for the 'Dir' command.   The same can be done with any other commands (not just pure DOS ones) which can be run from the Command Prompt.   If the command has no switches available, or this minimal 'Help' feature does not exist for a command, you will get the message:
       Bad command or filename

The main switches for commands included in this article are listed with their commands. Note that any given switch may well not mean the same thing or be valid if used with other commands. Obscure and specialist ones have been omitted for the sake of brevity.
Printing
After using the   >PRN   'switch', you may have to tell your printer to continue (use its 'Feed' button) if the file does not take up a whole page.   The same applies if you press   Print Screen   in the middle of a   |MORE   display to print part of a file. DOS is not very good at controlling printers. They expect to get at least a pageful before they will print, or be told automatically that they've got all there is, so get on with it. You have to give them a nudge!

If you print from a DOS Box, don't expect the Printer icon to pop up in your SysTray just because Windows is running. It won't as it is taking its orders from DOS.
Wildcards
DOS accepts the standard Wildcard character ( * ) in commands as the first or last part of a filename (or both), but not in directory names. Commands like ATTRIB, DIR, DEL and REN (Attributes, Directory List, Delete and Rename) can therefore be applied to numbers of files in a specified directory.   Thus:
     C:\XX\*.*      means 'any file' in the   C:\XX\   directory.
     C:\YY\*.DOC     means 'all files with the Doc extension'.
     C:\ZZ\CONFIG.*   means 'all Config-something files' (config.sys, config.syd, config.old etc).

They will also apply to files in sub-directories where the command can include such a switch (often /S ).
Top of Page     Main Topic Index

F1 & F3
These keys speed up the sometimes laborious process of typing commands and reduce typing errors. Both repeat the last thing you typed at the command prompt. F1 does this character-by-character and allows you to type another one in place of one which perhaps you didn't mean or which you want to change. F3 types the whole thing, and allows you to add something to the end, or use the backspace to alter the end, saving having to restart a long one from the beginning. For example:

Say you typed   FORMTA A: /U   instead of   FORMAT A: /U   and got back the   ' Bad command or filename '   response. Simply Press F1 until you have   FORM   then type the correct   AT   ending, then press F3 to get the rest of the command. Note that this only works where the number of characters is the same as before.

Or suppose you forgot to add   /P   at the end of a DIR command, and the list scrolled by too fast to read. Just hit F3 and add the 'Pause' switch.
Clearing the Screen
A DOS screen can become cluttered. To clear it and start at the top again, simply type   CLS    [Enter]
 
Top of Page     Main Topic Index

A Note on DOSKEY
Advanced users may extoll the virtues of DOSKEY, a utility which can be loaded to remember the last several commands given. It is not necessary unless one does a lot of work in DOS Mode, and even then has - in my view - two significant disadvantages.
Firstly, it does not recall commands between sessions, and to get it to do so one has to write a complicated batch file with those commands and run it before DOSKEY will remember them (whilst not actually running the commands at that stage!).   Secondly, it is memory-hungry even if unused.
Batch files on the other hand are always there, and take no resources except when running. DOSKEY was useful before Win9x when much system maintenance etc had to be done in DOS mode, and is still is use for this in certain circumstances.
Top of Page     Main Topic Index

Next Page

< Home >