Dos Commands

 

CD (Change Directory)
Internal Command
Displays the name of or changes the current directory.
CHDIR [drive:][path]
CHDIR[..]
CD [drive:][path]
CD[..]
CD\ Specifies that you want to change to the root directory.
Examples:
cd..
Goes up one directory (i.e. from c:\windows\command> to c:\windows>)
cd\
Goes to root directory of drive (i.e. from c:\windows\command> to c:\>)
cd windows
Changes to that directory from the directory above it (i.e. c:\> to c:\windows>)
cd\windows\command
Changes to the directory regardless of what directory you are currently in, as long as you are on the same drive. (i.e. from c:\games> to c:\windows\command>)
cd h:\failsafe.drv\failsafe
Changes to directory regardless of where you are, even on another drive.

 

CHKDSK (Check Disk)
External Command
Checks a disk and displays a status report.
CHKDSK [drive:][[path]filename] [/F] [/V]
[drive:][path] Specifies the drive and directory to check.
filename Specifies the file(s) to check for fragmentation.
/F Fixes errors on the disk. (Use scandisk instead of this switch)
/V Displays the full path and name of every file on the disk.
Examples:
Chkdsk
Sample Output:
Volume Serial Number is 3441-1201
Errors found, F parameter not specified
Corrections will not be written to disk

7 lost allocation units found in 3 chains.
114,688 bytes disk space would be freed
1,054,605,312 bytes total disk space ç Drive Size
8,552,448 bytes in 133 hidden files
6,356,992 bytes in 383 directories
685,801,472 bytes in 4,997 user files
353,779,712 bytes available on disk ç Free Disk Space
16,384 bytes in each allocation unit ç Cluster Size
64,367 total allocation units on disk ç Clusters
21,592 available allocation units on disk
655,360 total bytes memory ç Total Conventional Memory
602,864 bytes free
Instead of using CHKDSK, try using SCANDISK. SCANDISK can reliably detect and fix a much wider range of disk problems.
Chkdsk is good for determining free and total disk space in place of "Dir /a/s" from the root.

 

COPY
Internal Command
COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination
[/A | /B]] [/V] [/Y | /-Y]
source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line
Copies one or more files to another location. To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).
Examples:
COPY sys*.?a? c:\windows\command
Will copy all files beginning with "SYS" and with the second letter "A" in the extension, from the directory that you are in to the windows command directory without changing the name.
Copy config.sys config.syx
Will backup the config.sys to config.syx.
Copy autoexec.bat > LPT1
Will copy the text to the autoexec.bat to a printer hooked to LPT1.
Copy CON mytext.txt
Will copy the next lines you type to a text document "mytext.txt". To get back to a prompt type F6 followed by <ENTER>. This is especially useful when you don’t have use of a text editor (i.e. EDIT.COM).
Copy t1.txt + t2.txt
Will append the text in "t2.txt" to "t1.txt".
Copy t1.txt + t2.txt t3.txt
Merges T1.txt and T2.txt into a new text document t3.txt

 

DEBUG
External Command
Runs DEBUG an EXTREMELY powerful and consequently a VERY DANGEROUS command when used improperly. Use only when specified by a Q article or under the instructions of a mentor.
Also see:
Q105940 – Troubleshooting Serial Port Problems Windows (good for both COM & LPT problems)
Q151715 – How to Toggle the CAPS LOCK and NUM LOCK keys

 

DIR (Directory Listing)
SET DIRCMD=
Internal Command
DIR [drive:][path][filename] [/P] [/W] [/A[[:]attributes]]
[/O[[:]sortorder]] [/S] [/B] [/L] [/V]
[drive:][path][filename]
/P Pauses after each screenful of information.
/W Uses wide list format.
/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files - Prefix meaning not
/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date & time (earliest first)
G Group directories first - Prefix to reverse order
A By Last Access Date (earliest first)
/S Displays files in specified directory and all subdirectories.
/B Uses bare format (no heading information or summary).
/L Uses lowercase.
/V Verbose mode.
Displays a list of files and subdirectories in a directory. Switches may be preset in the DIRCMD environment variable. Override preset switches by prefixing any switch with - (hyphen)--for example, /-W.

Examples:
Dir /a/s/p sys*.??t
When typed from the C:\> prompt will show all files on the hard drive beginning with "SYS" and ending with "T" as the last letter in the extension. This example would show both "SYSTEM.1ST" and "SYSTEM.DAT" among others.
Dir /p/od config.*
Will show all files in the current directory named config, from oldest to newest, pausing after each full screen of information.
Dir /a/og/p/w
Will show all files in a given directory with the directories listed first, followed by files alphabetized by their extension, all display in wide-screen format.
SET DIRCMD=/a/p/w/on
Every time you type DIR in the boot session after you type the DIRCMD line it will automatically put in the switches you put after the = in the DIRCMD line.

 

DRIVPARM (Drive Parameters)
Internal Command
Sets how a floppy drive is to be read and written to. (Syntax for line in config.sys shown below).
Also see:
Q118580 "Troubleshooting DMF Floppy Disks" for usage.
Example:
For a 1.44-MB A: drive
DRIVPARM=/d:0 /f:7
For a 1.44-MB B: drive
DRIVPARM=/d:1 /f:7

 

ECHO
Internal Command
ECHO [ON | OFF]
ECHO [message]
Messages, or turns command-echoing on or off.
Good for redirecting ">" and appending ">>" commands to ports and documents.
Examples:
Echo device=c:\cd-rom\drv\sbcd.sys /d:mscd001 >> config.sys
Appends the device line to the config.sys
Echo mscdex /d:mscd001 > c:\autoexec.bat
If there was an autoexec.bat this would have erased it and put this one line in it. If there wasn’t and autoexec.bat, it would have created one and put this one line in it.
Echo ATDT>COM2
Sends a command to give a dial-tone to the modem on COM2.
Echo TEST>LPT1
Sends the ASCII text word "TEST" to the parallel port LPT1. If all is working properly the printer should print the word "TEST". Also see COPY for more printer tests.

 

EXTRACT
External Command
EXTRACT [/Y] [/A] [/D | /E] [/L dir] cabinet [filename ...]
EXTRACT [/Y] source [newname]
EXTRACT [/Y] /C source destination
cabinet - Cabinet file (contains two or more files).
filename - Name of the file to extract from the cabinet.
Wild cards and multiple filenames (separated by
blanks) may be used.
source - Compressed file (a cabinet with only one file).
newname - New filename to give the extracted file.
If not supplied, the original name is used.
/A Process ALL cabinets. Follows cabinet chain
starting in first cabinet mentioned.
/C Copy source file to destination (to copy from DMF disks).
/D Display cabinet directory (use with filename to avoid extract).
/E Extract (use instead of *.* to extract all files).
/L dir Location to place extracted files (default is current directory).
/Y Do not prompt before overwriting an existing file.
Used for getting a particular file out of a CAB File (i.e. WIN95_02.CAB, PLUS1.CAB, PRECOPY2.CAB…).
 Examples:
Extract a:\win95_09.cab *.exe /L c:\windows\command
Extracts all EXE's in CAB 9 on Disk #9 in floppy drive a:\ to the windows command directory.
Extract /c a:\win95_13.cab c:\w95flat
Copies CAB 13 from disk 13 DMF floppy to the c:\w95flat directory.
Extract /a d:\win95\win95_02.cab himem.sys /L c:\windows
Searches all cab files in the WIN95 directory on the D: drive (starting with CAB 2) for himem.sys and when found extracts it to the Windows directory.
Examples of Batch files:
A handy one for someone who has a flat file or CD-ROM.
edit x.bat
d:\win95\extract mini.cab %1 /L c:\windows%2
d:\win95\extract /a precopy1.cab %1 /L c:\windows%2
d:\win95\extract /a win95_02.cab %1 /L c:\windows%2
<save and exit out>
Syntax for usage
X himem.sys
(Will extract himem to the c:\windows directory)
X mscdex.exe \command
(Will extract mscdex.exe to the c:\windows\command directory)
A handy one for copying the DMF floppies to a flat file, you’ll still need to manually copy disk 1 and manually extract PRECOPY2.CAB from disk 2, but it works for the rest of 2 – 13. See Q136628 for more details. Remember disk 1 can just be copied and disk 2 has 2 cab files on it.
Edit x2.bat
Extract /c a:\win95_%1.cab c:\w95flat
<save and exit>
Syntax for usage
X2 <disk number (i.e. 02,03,04…11,12,13)>
X2 04

 

FC (File Compare)
External Command
FC [/A] [/C] [/L] [/N] [/T] [/W] [drive1:][path1]filename1
[drive2:][path2]filename2
FC /B [drive1:][path1]filename1 [drive2:][path2]filename2
/A Displays only first and last lines for each set of differences.
/B Performs a binary comparison.
/C Disregards the case of letters.
/L Compares files as ASCII text.
/N Displays the line numbers on an ASCII comparison.
/T Does not expand tabs to spaces.
/W Compresses white space (tabs and spaces) for comparison.
Compares two files or sets of files and displays the differences between them. Particularly useful after exporting before and after copies of the registry, or doing before and after directory listing that you want to see what gets modified in some process.
Examples: (unlike the other examples these are more global examples.)
regedit /e reg1.txt
<make change in registry (i.e. Run POLEDIT)>
regedit /e reg2.txt
FC reg1.txt reg2.txt > regsam.txt
Edit regsam.txt
Example 1 would be a good way to use FC to see what something is doing to you registry.
dir /a/s > dir1.txt
<make change to drive>
dir /a/s > dir2.txt
FC dir1.txt dir2.txt > dir3.txt
Edit dir3.txt
Example 2 would be a good way to see what files are added or removed from your drive during a process. For best results do this from the root.

 

MD (Make Directory)
Internal Command
Creates a directory.
MKDIR [drive:]path
MD [drive:]path
Examples:
MD w95flat
Creates a sub-directory in what ever directory you typed the command.
MD c:\windows\infback
Creates an empty directory in the windows directory called "infback".

 

MEM
External Command
Displays the amount of used and free memory in your system.
MEM [/CLASSIFY | /DEBUG | /FREE | /MODULE modulename] [/PAGE]
/CLASSIFY or /C Classifies programs by memory usage. Lists the size of programs, provides a summary of memory in use, and lists largest memory block available.
/DEBUG or /D Displays status of all modules in memory, internal drivers, and other information.
/FREE or /F Displays information about the amount of free memory left in both conventional and upper memory.
/MODULE or /M Displays a detailed listing of a module's memory use. This option must be followed by the name of a module, optionally separated from /M by a colon.
/PAGE or /P Pauses after each screenful of information.
Examples:
Mem /c /p
Sample Output on Next Page:
Modules using memory below 1 MB:
Name Total Conventional Upper Memory
-------- ---------------- ----------------- ----------------
MSDOS 17,248 (17K) 17,248 (17K) 0 (0K)
HIMEM 1,168 (1K) 1,168 (1K) 0 (0K)
IFSHLP 2,864 (3K) 2,864 (3K) 0 (0K)
SETVER 832 (1K) 832 (1K) 0 (0K)
WIN 3,568 (3K) 3,568 (3K) 0 (0K)
vmm32 3,040 (3K) 3,040 (3K) 0 (0K)
COMMAND 7,424 (7K) 7,424 (7K) 0 (0K)
Free 614,912 (601K) 614,912 (601K) 0 (0K)
Memory Summary:
Type of Memory Total Used Free
---------------- ----------- ----------- ------------
Conventional 655,360 36,352 614,912 (See #Note)
Upper 0 0 0
Reserved 0 0 0
Extended (XMS) 32,505,856 163,840 32,342,016
---------------- ----------- ----------- ------------
Total memory 33,157,120 200,192 32,956,928
Press any key to continue . . .
Total under 1 MB 655,360 36,352 614,912
Total Expanded (EMS) 33,062,912 (32M)
Free Expanded (EMS) 16,777,216 (16M)
Largest executable program size 614,896 (600K)
Largest free upper memory block 0 (0K)
MS-DOS is resident in the high memory area.
#Note
The Machine this was sampled from has an ADAPTEC SCSI 2920 SCSI Host Adapter so the Total Conventional Memory was actually 651,264 (It load a 4K SCSI card BIOS on boot.) The Numbers have been manually alter to reflect a more standard configuration, however some of the columns may not add up quite right.

 

MSCDEX (Microsoft Compact Disk Extensions)
External Command
MSCDEX [/E/K/S/V] [/D:<driver> ... ] [/L:<letter>] [/M:<buffers>]
/D: Calls the working name for the drive that was assigned to it in the config.sys
/L: Assigns a drive letter to the drive
/M: Buffers (Speeds up accesses times)
/E Tells MSCDEX.EXE to use expanded memory if your system is using expanded memory.
/V Displays information on memory usage when you boot your PC.
Also See:
Q87165 - Command-Line Switches for MSCDEX.EXE
Attached Document – " Problems accessing CD-ROM in DOS".
Examples:
Mscdex /d:mscd001 /l:Y
Assigns device driver with a name of MSCD001 to drive Y:

 

MOVE
External Command
Moves files and renames directories.
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2
[drive:][path]filename1 Specifies the location and name of the file or files you want to move.
destination Specifies the new location of the file. Destination can consist of a drive letter and colon, a directory name, or a combination. If you are moving only one file, you can also include a filename if you want to rename the file when you move it.
[drive:][path]dirname1 Specifies the directory you want to rename.
dirname2 Specifies the new name of the directory.
/Y Suppresses prompting to confirm creation of a directory or overwriting of the destination.
/-Y Causes prompting to confirm creation of a directory or overwriting of the destination.
The switch /Y may be present in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.
Used to rename directories in lieu of REN.
Examples:
Move inf infback
Renames the INF directory to INFBACK.
Move c:\windows\inf infback
Renames the INF directory to INFBACK, but the user didn’t need to be in the windows directory when they typed this command.
Move c:\config.* c:\backup
Moves all files named "Config" from the root of C:\ to the backup directory.
Move mytext~1.doc c:\mydocu~1
Moves the long file name "My Text Document.doc" to the long file name directory "My Documents" on the C: drive.

 

PRINT
External Command
One of a couple commands discontinued in DOS 7.0. Any usage of the command is unsupported. This command, along with some other old DOS commands are available for download and available on the CD-ROM in the \OTHER\OLDMSDOS Directory.
Listed are the other OLDMSDOS commands:
APPEND EXE 10,774 07-11-95 9:50a APPEND.EXE
CHKSTATE SYS 41,600 07-11-95 9:50a CHKSTATE.SYS
EXPAND EXE 16,129 07-11-95 9:50a EXPAND.EXE
GRAPHICS COM 19,742 07-11-95 9:50a GRAPHICS.COM
GRAPHICS PRO 21,232 07-11-95 9:50a GRAPHICS.PRO
HELP COM 413 07-11-95 9:50a HELP.COM
HELP HLP 301,961 07-11-95 9:50a HELP.HLP
INSTSUPP BAT 2,872 07-11-95 9:50a INSTSUPP.BAT
INTERLNK EXE 17,197 07-11-95 9:50a INTERLNK.EXE
INTERSVR EXE 37,426 07-11-95 9:50a INTERSVR.EXE
LOADFIX COM 1,131 07-11-95 9:50a LOADFIX.COM
MEMMAKER EXE 119,557 07-11-95 9:50a MEMMAKER.EXE
MEMMAKER HLP 17,237 07-11-95 9:50a MEMMAKER.HLP
MEMMAKER INF 2,911 07-11-95 9:50a MEMMAKER.INF
MONOUMB 386 8,783 07-11-95 9:50a MONOUMB.386
MSBACKUP <DIR> 07-11-95 9:50a MSBACKUP
PRINT EXE 15,656 07-11-95 9:50a PRINT.EXE
QBASIC EXE 194,309 07-11-95 9:50a QBASIC.EXE
QBASIC HLP 130,881 07-11-95 9:50a QBASIC.HLP
REPLACE EXE 20,274 07-11-95 9:50a REPLACE.EXE
RESTORE EXE 38,342 07-11-95 9:50a RESTORE.EXE
SIZER EXE 7,169 07-11-95 9:50a SIZER.EXE
TREE COM 6,945 07-11-95 9:50a TREE.COM
UNDELETE EXE 26,416 07-11-95 9:50a UNDELETE.EXE
23 file(s) 1,058,957 bytes

 

RD (Remove Directory)
Internal Command
Removes (deletes) an empty directory.
RMDIR [drive:]path
RD [drive:]path
Just use DELTREE.

 

REN (Rename)
Internal Command
Renames files and directories
RENAME [drive:][path][directoryname1 | filename1] [directoryname2 | filename2]
REN [drive:][path][directoryname1 | filename1] [directoryname2 | filename2]
Use in place of DEL or preferably use COPY followed by DEL as REN doesn’t confirm that the command has been executed, where as COPY does. Note that you cannot specify a new drive or path for your destination (target) file.
Examples:
REN Autoexec.bat *.BTX
Renames autoexec.bat to autoexec.btx
REN *.1st *.1xx
Renames all files ending in 1st to 1xx extensions.
REN Config.sys Config.syx
Renames the Config.sys to Config.syx
REN inf infback
Renames the INF directory to INFBACK.
REN c:\windows\inf infback
Renames the INF directory to INFBACK, but the user didn’t need to be in the windows directory when they typed this command.

 

SCANDISK
External command
Runs the ScanDisk disk-repair program.
To check and repair a drive, use the following syntax:
SCANDISK [drive: | /ALL] [/CHECKONLY | /AUTOFIX [/NOSAVE]] [/SURFACE]
To check and repair an unmounted Drivespace compressed volume file, use:
SCANDISK drive:\DRVSPACE.nnn [/CHECKONLY | /AUTOFIX[/NOSAVE]]
To examine a file for fragmentation, use the following syntax:
SCANDISK /FRAGMENT [drive:][path]filename
To undo repairs you made previously, use the following syntax:
SCANDISK /UNDO [drive:]
For [drive:], specify the drive containing your Undo disk.
/ALL Checks and repairs all local drives.
/AUTOFIX Fixes damage without prompting.
/CHECKONLY Checks a drive, but does not repair any damage.
/CUSTOM Configures and runs ScanDisk according to SCANDISK.INI settings.
/NOSAVE With /AUTOFIX, deletes lost clusters rather than saving as files.
/NOSUMMARY With /CHECKONLY or /AUTOFIX, prevents ScanDisk from stopping at
summary screens.
/SURFACE Performs a surface scan after other checks.
/MONO Configures ScanDisk for use with a monochrome display.
To check and repair the current drive, type SCANDISK without parameters.
Used to find and fix disk errors. Extremely useful in dealing with compression.
Also see:
Q133175 – Troubleshooting Drivespace in Windows 95 (KNOW THIS ARTICLE!)
Examples:
Scandisk c: /all
Will scan all fixed disks
Scandisk h: /AUTOFIX
Will scan and not prompt to fix errors. Be careful with this as you can really damage a customers data with this one, use only in extreme cases.
Scandisk /all /surface
Performs a "Thorough" scan on all fixed disks.
Scandisk C:\dblspace.000
Mounts (or attempts to mount) the CVF (Compressed Volume File) dblspace.000. Remember the version of scandisk that you use must match up to the version of compression you use. (i.e. If you compress with Drivespace 2 [Standard Windows 95], your scandisk.exe needs to be dated 7-11-95, If you compress with Drivespace 3 [Plus! Pack], your scandisk.exe should be dated 7-14-95. OSR2 is a whole different story.)
Scandisk /mount=000 c:
Will try to mount the CVF ending in .000 in the root of the C: drive. Just use scandisk /all, it will do the same thing and it’s easier.

 

SET
Internal Command
Displays, sets, or removes Windows environment variables.
SET [variable=[string]]
variable Specifies the environment-variable name.
string Specifies a series of characters to assign to the variable.
Type SET without parameters to display the current environment variables.
Examples:
Set DIRCMD=/on/a/p
After typing this line, whenever the user types DIR it will automatically add the three switches listed.
Set Path=A:\
When you type a command it will search the directory you typed the command in for the executable (COM, EXE, BAT [in that order]), then search the path (in this case A:\) for the executable. This is good for when you boot from a safe boot disk and need to type a lot of commands on the hard drive.
Set Path=%path%;c:\windows\command;c:\dos
Appends the C:\windows\command and c:\dos directories to the end of the path statement

 

SYS (System Transfer)
External Command
Copies MS-DOS system files and command interpreter to a disk you specify.
SYS [drive1:][path] drive2:
[drive1:][path] Specifies the location of the system files.
drive2: Specifies the drive the files are to be copied to.
Makes the disk bootable.
WARNING –
If a customer has a DISK MANAGER or DRIVE OVERLAY (EZ-Drive, On Track Disk Manager, Etc…), and the disk manager has written to the boot sector to load, you will overwrite the disk manager when you sys the drive. What does this mean? Effectively it will ERASE their ENTIRE drive! The good news is if they talk to there disk manager manufacturer they PROBABLY can get all there data back. But it is an EXTREMELY good idea to check with a mentor before sys-ing a drive.
Also see:
Q128730 – "Error Message" Invalid System Disk After Installing Windows 95

Example:
Sys a:
Makes disk in A: bootable.
Sys h: a:
Makes A: bootable with the system files from H:

 

TYPE
Internal command
Displays the contents of text files.
TYPE [drive:][path]filename
Examples:
Type config.sys
Shows the contents of the config.sys
Type C:\autoexec.bat
Shows the contents of autoexec.bat
Type c:\windows\system.ini | more
Shows the contents of the System.ini and pause after each full screen of information, however the more command must be present in the path (see SET for details on PATH) . Pipe ( | ) is usually the SHIFT + \ key.

 

VER (Version)
Internal Command
Displays the Operating System version.
Example:
VER
Expected output:
Windows 95. [Version 4.00.950]
or something about DOS 7.0.

 

XCOPY
XCOPY32

External Commands
Copies files (except hidden and system files) and directory trees.
XCOPY source [destination] [/A | /M] [/D:date] [/P] [/S [/E]] [/V] [/W]
source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies files with the archive attribute set,
doesn't change the attribute.
/M Copies files with the archive attribute set,
turns off the archive attribute.
/D:date Copies files changed on or after the specified date.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies any subdirectories, even if empty.
/V Verifies each new file.
/W Prompts you to press a key before copying.
*Note: More switches are available in a DOS VM than in pure DOS, but if you can get to a DOS VM you should be able to drag-n-drop or copy and paste as opposed to using XCOPY.
Copies files, directories, and sub-directories (except hidden and system).

Examples:
Xcopy /s c:\windows\inf c:\infback
Copies the INF directory and all it’s subdirectories to a backup directory in the root.
Xcopy /a/e c:\*.da? c:\backup\*.da?
Copies all DA? (where ? is a wildcard) files on the drive to a backup directory.

 

> (Redirect)
>> (Append)
Internal Switches (Redirectors)
Used to reroute the output of a command.
Examples:
Dir /? > dirhelp.txt
Saves the help info for DIR command to a text document, dirhelp.txt.
Dir /a/s > dirlist.txt
Saves a list of all the files listed on drive (except those in hidden directories [like failsafe.drv]).
Echo ATDT5555555>COM2
Sends a simple dial command the COM2 (you should hear a modem dial if things are working properly).
Echo HELLO>LPT1
Sends simple text to the printer on LPT1 (the printer should print "Hello")
Echo mscdex /d:mscd001>>c:\autoexec.bat
Adds "mscdex /d:mscd001" (without quotes) to the bottom of the Autoexec.bat
Debug < num_on.deb
Send a DEBUG script to debug command (use only as directed by a mentor)  

HOME