Home Page 3
Index Next Page
DOS for Windows9x

Essential DOS Commands

CommandFor CommandFor
AttribAmending File Attributes DelDeleting Files
DirListing Directories & Finding Files ExtractExtracting Files from Floppies/CDs
FormatFormatting Disks or Drives MscdexCD-ROM Access
MDMaking (Creating) Directories RenRenaming Files
RegeditImporting & Exporting Registry ScandiskScanning Disks for Errors
XCopyCopying Files in DOS Mode WinLaunching Windows from DOS
Using DOS Commands      Further Commands      Main Topic Index

ATTRIB - Changes the Attributes of Files.
Usage:
       ATTRIB switches filename
Switches:
  • +   Sets an attribute.
  • -   Clears an attribute.
  • R   Read-only attribute.
  • A   Archive attribute.
  • S   System attribute.
  • H   Hidden attribute.
  • /S   Processes files in all sub-directories in the specified path.
Examples:
       ATTRIB -r -a -s -h C:\WINDOWS\SYSTEM.DAT   removes the Read-only, Archive, System and Hidden attributes.

       ATTRIB +R CONFIG.SYS   makes Config.sys a Read-only file (eg to prevent tampering by casual users).

       ATTRIB +H +R D:\DOCS\*.DOC /S   makes all *.doc files in the directory D:\DOCS and any sub-directories Hidden and Read-only.

Note: DOS cannot remove all Win9x files from a hard drive by simply removing all System and Hidden attributes and then deleting them. It will decline to delete certain key files, which is why a FORMAT may be necesssary to clear a drive before a Windows re-install.
DEL - Deletes Files.
Usage:
       DEL path+name switch
Switch:
       /P   asks before deleting each file.
Examples:
       DEL C:\BACKUP.OLD   deletes the specified file.
       DEL C:\TESTS\*.* /P   deletes all files in the   C:\TESTS\   directory and asks before deleting each one.
Top of Page     Main Topic Index

DIR - Lists the contents of a Directory & finds Files.
Usage:
       DIR /switches
       DIR c:\directory\sub-directory /switches
       DIR filename /switches
Switches:
  • /O:     Sorting Order:
    • /O:N   Sort by Name
    • /O:A   Sort by last Access date
    • /O:D   Sort by normal Date
    • /O:S   Sort by Size
    • /O:E   Sort by Extension
    • /O:G   Sort by Directories - Grouped first
    • /O:-   Sort in reverse order
      (eg: /O:-N sorts by Name, beginning at Z)
  • /S   List current Directory & Sub-directories
  • filename   Finds the specified file.
  • /A     Attributes of files to be listed:
    • /AD   Directories only (not files)
    • /AH   Display Hidden files
    • /AS   Display System files
    • /AR   Display Read-only files
    • /A-   Do not display
      (eg: /A-H omits Hidden files)
  • /V   Verbose - List all details (see note).
  • /P   Pause after each screenful.
  • >PRN   Sends the results to the Printer.
  • >filename   Sends the result to a File.
Examples:
       DIR C:\GAMES\TENNIS >PRN    will give a printout of the specified directory, in no particular order.

       DIR C:\GAMES\TENNIS >C:\TENNIS.TXT    will save a listing of the specified directory as above, in a text file. This can be read and edited using any text editor (including the DOS one), and printed later if required.

       DIR /O:-GN /A-H-S /S /V /P    means 'Sort by Name grouping Directories last, exclude Hidden and System files, list the current Directory and Sub-directories, give All details, and Pause between Pages.'

       DIR C:\WINDOWS /O:N /A-D /S /4 >PRN    means 'Print a list of the C:\WINDOWS and Sub-directory files, Sorted by Name, omitting extra Directory names, use 4-digit Dates (see note)'.   - a useful combination for printing.

       DIR COMMAND.COM /S    will look for   COMMAND.COM   in the current and all sub-directories, and list it as many times as it occurs.

       D:\PICS\>DIR *.JPG /ON /S >C:\PICS.TXT    will look for files with the JPG extension in   D:\PICS\   and sub-directories, list them in name order (by directory) and save the listing as   C:\PICS.TXT.
  • DIR   is a harmless Command, so if you want to practice moving around in DOS and typing a few varied switches, use it rather than a command which alters anything ...
  • The   /4   (4-digit-date) Switch:   If you have applied the Win95 Year 2000 Update which enables   DIR   to report the year part of dates in full as 1999, 2000 etc, the   /4   switch may be used to force full dates to be listed. Use of the   /4   switch disables the   /V   switch.   Ho, hum ...
  • Used in a DOS Box,   DIR   lists files and directories in the DOS '8.3' mode, but includes the Long File Names alongside.   If you want printouts of file listings without installing yet another Shareware add-in, do it from a DOS Box, therefore!
  • A Tip: Use the ' > ' switch to save longer listings to a text file. Open the file and edit out the extra stuff DOS sticks in before printing.
Top of Page     Main Topic Index

EXTRACT - Extracts compressed files from a floppy disk or CD.
Usage:
       EXTRACT switches [Location+Filename] [Destination+Filename]
Switches:
  • /A   Process all cabinets. Follows cabinet chain starting in first cabinet specified.
  • /C   Copy source file to destination (for 1.8Mb DMF software disks).
  • /D   Display the Cabinet directory (used with a filename to avoid extraction).
  • /E   Extract all files (used instead of   *.* ).
  • /L dir   Location for extracted files. The default is the current directory.
  • /Y   Do not ask before overwriting existing files. The default action is to prompt for what to do.
Examples:
       EXTRACT A:\MAIN\VITAL.DL_ C:\WINDOWS\SYSTEM\VITAL.DLL
This is useful for a repair, involving a known missing or corrupt file, which cannot be done while Windows is running. You must know the location (pathname) of the good version and where it is to go. In this example, the file   Vital.dl_   on floppy drive A: is specified and extracted from its compressed state to the correct directory with the full extension name. All files on installation CDs and floppies which have a ' _ ' as their last letter must be Extracted, not just copied across and renamed.

       EXTRACT /D D:\WIN95\win95_02.cab |MORE    Displays a list of the contents of the 'Cabinet' file on the Win95 CD. Useful if you have not got a Cab File Viewer or WinZip (whose current version handles '*.cab' files like zipped ones and can Extract individual files).

       EXTRACT /A /D D:\WIN98\base4.cab >C:\cablist.txt    Lists the contents of all the 'Cab' files on the Win98SE CD in a file called   cablist.txt.   This is quicker and more accurate than collecting lists from elsewhere as it lists your particular CD version. The file will be large, so open it with a Word Processor to do a search for a particular file you wish to Extract. Specify the first 'Cab' file in the  \Win9x  folder on your CD.

       EXTRACT /Y D:\WIN95\win95_02.cab\HYPERTRM.DLL /L C:\PROGR~1\ACCESS~1\HYPERT~1    Extracts the original version of   HYPERTRM.DLL   to its correct location and overwrites the existing version without prompting.
Top of Page     Main Topic Index

FORMAT - Formats a floppy or hard disk drive for use by the Operating System.
Usage:
       FORMAT x: /switches   where 'x' is the letter of the drive to be formatted.
Switches:
  • /U   An Unconditional format; wipes the entire disk clean and re-formats it.
  • /Q   A Quick format, which simply erases existing data.
  • /S   Copies System files to the disk after formatting. These will come from the floppy if one is being used to format a hard drive, or from the hard drive if a floppy is being formatted.
  • /V:Text   Gives the Volume (disk) a label (name). If this switch is not used, DOS will ask if you want one at the end.
  • /C   Tests Clusters previously marked as 'bad' (eg by Scandisk) to see if they really are.
Example:
       FORMAT D: /U /C /V:Data
formats drive D: Unconditionally, tests any Clusters marked as bad, and gives it the name 'Data'.

There are more switches for specific types of floppy disk. (Type   format /?   to see the full list). DOS assumes a standard floppy drive will use the standard 1.4Mb size, so these are only required if a non-standard disk is being formatted. In the case of a hard drive (or the specified partition on a partitioned drive) DOS will automatically detect the size.

FORMAT must be run after FDISK. It does not itself have the ability to partition a hard drive, or distinguish between FAT16 and FAT32. This is irrelevent for a floppy, but for a hard drive use FDISK or 'Partition Magic' first to specify the FAT and partitions.

Security: Note that formatting a floppy or hard disk, with or without the   /U   switch, does not mean the data will be gone forever. Utilities exist which can retrieve it, so don't pass on old floppies or hard drives you've formatted thinking your private files cannot be read.
Top of Page     Main Topic Index

MSCDEX - Enables DOS Mode access to a CD-ROM.
Usage:
       MSCDEX /D:x /L:y /other switches
Switches:
  • /D:   specifies the Device name. Mandatory. Last character must be a number, eg:   MSCD001 , CDROM02.
  • /L:   specifies the drive Letter. Mandatory. eg:   /L:D , /L:E
  • /E   tells Mscdex to use Expanded memory. Optional
  • /S   Sharing permitted, on a network. Optional
  • /V   Verbose. Tells Mscdex to display details on loading. Optional
  • /K   is for accessing CDs with files in the Japanese Kanji format.
  • /M:   specifies the number of sectors to cache in Memory. Optional. Default = 10, each sector using c 2K of memory.
  • /Others   are added by the device driver (Cdrom.sys or whatever it is on your setup). Don't change them.
Mscdex can be run from the command prompt but is more usually included in   C:\Windows\Dosstart.bat   or a Boot Disk's   Autoexec.bat   (see Guide to Re-Installing Win9x). It must also have the CD-ROM's DOS mode driver pre-loaded, which is not possible from the DOS prompt, only by a line in Config.sys.

Example:
       MSCDEX /D:MSCD001 /L:D /V    loads MSCDEX, allocates the CD-ROM drive the letter 'D' and the device name 'MSCD001', and tells MSCDEX to load in verbose mode (ie say what is happening).
 
Top of Page     Main Topic Index
MD - Creates a Directory.
Usage:
       MD path+name
Examples:
       MD D:\DATA   creates a new directory.
       MD D:\DATA\DOWNLOAD   creates a new Sub-directory. You cannot create a Sub-directory until the main directory exists.
Top of Page     Main Topic Index

REGEDIT - Imports and exports Registry files.
Use With Caution!
See Compacting Registry and Reg.bat

Usage:
       REGEDIT switches filename
Switches:
  • /C filename   specifies the file to Create Registry from.
  • /E filename   specifies the file to Export Registry to.
  • /D        Deletes Registry ... don't do it!
Examples:
       REGEDIT /E C:\EXPORT1.REG    specifies the file to use when Exporting Registry (making a copy).
       REGEDIT /C C:\EXPORT1.REG    specifies the file to use to Create (or rebuild) Registry.
 
REN - Renames a File or Directory.
Usage:
       REN path+name name
Examples:
       REN C:\WINDOWS\SYSTEM.BAK SYSTEM.BA1   renames the file in the same directory.
       REN D:\DATA\DOWNLOAD MISC   renames the D:\DATA\DOWNLOAD directory to D:\DATA\MISC.

Do not enter the full path for the name the file or directory is to be renamed to.
Top of Page     Main Topic Index

SCANDISK - checks a drive for errors.
Usage:
       scandisk drive switches
Switches:
  • /CUSTOM   Runs Scandisk with the options set under 'Custom' in SCANDISK.INI.
  • /ALL   Checks all drives and fixes errors.
  • /AUTOFIX   Fixes errors without asking.
  • /CHECKONLY   Checks and reports only.
  • /NOSAVE   (With /AUTOFIX) Deletes lost clusters.
  • /NOSUMMARY   (With /AUTOFIX & /CHECKONLY) Does not pause between drives to report.
  • /UNDO X:   Undoes the repairs last made using the Undo disk in Drive X.
  • /SURFACE   Does a surface check.
Examples:
       SCANDISK   tells Scandisk to check the current drive, using the default settings in   SCANDISK.INI.
       SCANDISK C: /CUSTOM   tells Scandisk to check drive C: with the Custom options specified in   SCANDISK.INI.
       SCANDISK D: /SURFACE   tells Scandisk to check drive D: for normal errors and then run a surface check.
       SCANDISK /ALL /AUTOFIX /NOSAVE   tells Scandisk to check all drives on the hard disk, fix errors without asking, and not to save any lost cluster fragments it may find.

C:\Windows\Command\Scandisk.ini:   Open this file in the DOS Editor and have a look at the Default settings used by Scandisk. You may wish to change them. My preference is to tell it to 'Fix' most things, Delete Lost Clusters, and not to try to save any fragments to file. (The chances of being able to recover anything of significance from such files were always slight; they are slimmer than ever with things like Word 7/8 containing tons of rubbish not relevent to a particular document anyway!)
If you do edit the file, run Scandisk with the   /CUSTOM   switch.

Scandisk is a useful tool to have on a Boot Disk, to enable you to check the state of a Hard Disk and correct any errors. If a drive is suffering or won't boot, running Scandisk may solve the problem. The same applies where Windows' Disk Defragmenter (Defrag) fails to work and Scandisk under Windows fails to complete. Running Scandisk from DOS may cure the fault ... but that's not a promise!
Top of Page     Main Topic Index

XCOPY - Copying Files in DOS Mode.
Warning: In DOS mode XCOPY generates truncated (short) directory and filenames (see Long File Names). Try to stick to directories and files which conform to the DOS '8.3' standard. If you are not sure if a directory or filename name will be altered, use the DIR command to get a listing first.
One can use the plain   COPY   command, but as it is not as good I am ignoring it.

Usage:
       xcopy path+name path+name switches
Switches:
  • /A   copies files with the Archive attribute - not changed.
  • /M   copies files with the Archive attribute - changed.
  • /P   asks before creating each new files.
  • /E   copies sub-directories, including empty ones.
  • /S   copies sub-directories, excluding empty ones.
  • /V   verifies new files are correctly copied.
  • /W   asks if you wish to continue before copying.
Examples:
       XCOPY C:\MYDOCU~1\*.* C:\BACKUPS\*.* /E /P /V
       copies the files in the 'C:\My Documents\' directory and sub-directories to another directory, asks if you wish to copy each file in turn, and ensures it has done so correctly.

       XCOPY C:\WINDOWS\SYSTEM.DAT C:\BACKUPS\SYSTEM.BAK /V
       copies the file to another directory with a different name and ensures it has done so correctly.
(Note: XCOPY will only copy a Hidden/System file if the Attributes have been temporarily removed first using ATTRIB).
Top of Page     Main Topic Index
WIN - Starts Windows from the DOS Prompt.
Usage:
       WIN
  • If you booted to the "Command Prompt Only" from the Boot Menu and now wish to get Windows going, type   WIN   and press Enter.
  • If you chose the "Safe Mode Command Prompt" option from the Boot Menu, do not use WIN to start Windows. Just Reboot (Ctrl+Alt+Del).
  • If you Shut Down Windows and chose "Restart the computer in MS-Dos mode" option, either Reboot (Ctrl+Alt+Del) or type   EXIT    [Enter].
Top of Page     Main Topic Index

Next Page

< Home >