Sort

Archived content. No warranty is made as to technical accuracy. Content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Reads input, sorts data, and writes the results to the screen, a file, or another device.

Sort acts as a filter, reading characters in a specified column and rearranging them in ascending or descending order.

On This Page

Syntax sort [ /r ] [/+n] [<] [drive1 : ][path1]filename1[> [drive2 : ][path2]filename2] [command |] sort [ /r ] [/+n] [> [drive2 : ][path2]filename2]
Stacks
Submenu
Subst
Switches
Sys
Time
Tree
Type
Undelete
Unformat
Ver
Verify
Vol
VSafe
Xcopy

Syntax sort [ /r ] [/+n] [<] [drive1 : ][path1]filename1[> [drive2 : ][path2]filename2] [command |] sort [ /r ] [/+n] [> [drive2 : ][path2]filename2]

Parameters

[ drive1 :][ path1 ] filename1

Specifies the location and name of the file whose data you want to sort.

[ drive2 :][ path2 ] filename2

Specifies the location and name of a file in which the sorted output is to be stored.

command

Specifies a command whose output is the data you want to sort.

Switches

/r

Reverses the order of the sorting operation; that is, sorts from Z to A, and then from 9 to 0.

/+ n

Sorts the file according to the character in column n. If you do not use this switch, the sort command sorts data according to the characters in column 1.

Notes

Specifying a source

Unless you specify the command or filename parameter, sort acts as a filter and takes input from the MS-DOS standard input (usually from the keyboard, from a pipe, or from a file).

Using redirection symbols with sort

You can use the pipe (|) or the less-than sign (<) to direct data through the sort command from command or filename. If you want to display the information one screen at a time or direct the information to a file, you can also specify the more command or a filename. You can use the greater-than sign (>) to direct the sorted output to a file.

Before using a pipe for redirection, you should set the TEMP environment variable in your AUTOEXEC.BAT file.

Collating sequence

The sort program uses the collating-sequence table corresponding to the country code and character set settings. Characters greater than ASCII code 127 are sorted based on information in the COUNTRY.SYS file or in an alternate file specified by the country command in your CONFIG.SYS file.

Uppercase vs. lowercase

Sort does not distinguish between uppercase and lowercase letters.

Limits on file size

The sort command can handle files as large as 64K.

Examples

The following command reads the file EXPENSES.TXT, sorts it in reverse order, and displays it on your screen:

sort /r < expenses.txt 

Suppose you want to search a large file named MAILLST.TXT for the text "Jones", and suppose you want to sort the results of the search. To do this, use the pipe (|) to direct the output of a find command to the sort command, as shown in the following example:

find "jones" maillst.txt | sort 

The command produces a sorted list of lines that contain the specified text.

To sort keyboard input and display the results alphabetically on the screen, you can first use the sort command with no parameters, as the following example shows:

sort 

Then type the text you want sorted, pressing ENTER at the end of each line. When you have finished typing text, press CTRL+Z, and then press ENTER. The sort command displays the text you typed, sorted alphabetically. You could also redirect sorted keyboard input to a file.

Related Command

For information about displaying information one screen at a time, see the more command.

Stacks

Supports the dynamic use of data stacks to handle hardware interrupts. You can use this command only in your CONFIG.SYS file.

Syntax stacks =n,s

Parameters

n

Specifies the number of stacks. Valid values for n are 0 and numbers in the range 8 through 64.

s

Specifies the size (in bytes) of each stack. Valid values for s are 0 and numbers in the range 32 through 512.

Notes

Default settings

The default settings for the stacks command are as follows:

Computer

Stacks

IBM PC, IBM PC/XT, IBM PC-Portable","

0,0

Other,

9,128

Special cases for stack allocation

Upon receiving a hardware interrupt, MS-DOS allocates one stack from the specified number of stacks. When you specify 0 for the n and s values, MS-DOS allocates no stacks. If the values are 0, each running program must have enough stack space to accommodate the computer's hardware interrupt drivers. Many computers operate correctly, saving some memory for programs, with n and s values of 0. If, however, your computer becomes unstable when you set these values to 0, return to the default values.

Increasing the value of stacks

If the stacks values are not equal to 0,0 and you see a "Stack Overflow" or "Exception error 12" message, increase the number or size of the stacks.

Example

To allocate 8 stacks of 512 bytes each for hardware-interrupt handling, add the following command to your CONFIG.SYS file:

stacks=8,512 

Defines an item on a startup menu that, when selected, displays another set of choices. You can use this command only within a menu block in your CONFIG.SYS file.

The startup menu is a list of choices that appears when you start your computer. You define a startup menu by using special CONFIG.SYS commands. Each item on the menu corresponds to a set of CONFIG.SYS commands called a "configuration block." A startup menu makes it possible to start your computer with a variety of configurations. For more information about defining multiple configurations, see the chapter "Configuring Your System" in the MS-DOS 6 User's Guide.

Syntax submenu =blockname[,menu_text]

Parameters

blockname

Specifies the name of the associated menu block. The menu block must be defined elsewhere in the CONFIG.SYS file and can contain menu-definition commands. Unlike the "main" menu block, which must have the block name [MENU], a menu block for a submenu can have any name you want. If MS-DOS cannot find a block with the specified name, the item does not appear on the startup menu. The block name can be up to 70 characters long and can contain most printable characters. It cannot include spaces, backslashes (\) and forward slashes (/), commas, semicolons (;), equal signs (=), and square brackets ([ and ]).

menu_text

Specifies the text you want MS-DOS to display for this menu item. If you don't specify any menu text, MS-DOS displays the block name as the menu item. The menu text can be up to 70 characters long and can contain any characters you want.

Example

The following CONFIG.SYS file defines a main startup menu and one submenu:

[menu]
menuitem base_config,Base configuration only
menuitem full_config,Normal configuration
submenu netmenu, Normal configuration with network
[netmenu]
menuitem lanman, Start Microsoft LAN Manager
menuitem vines, Start Banyan VINES
[base_config]
dos=high
device=c:\dos\himem
[full_config]
include=base_config
dos=umb
device=c:\dos\emm386 ram
device=c:\dos\ramdrive.sys 512
[lanman]
include=full_config
rem Commands for Microsoft LAN Manager would go here.
[vines]
include=full_config
rem Commands for Banyan VINES would go here

This CONFIG.SYS file provides a choice of four configurations: a basic configuration (base_config), a full configuration (full_config), and two network configurations. Both network configurations include all the commands in the full configuration; the lanman configuration runs Microsoft LAN Manager and the vines configuration runs Banyan VINES network software. To choose a network configuration, the user first selects item 3, "Normal configuration with network," from the main menu. MS-DOS then displays the network choices on the submenu.

When MS-DOS starts, it displays the following menu:

MS-DOS 6 Startup Menu
=====================
   1. Base configuration only
   2. Normal configuration
   3. Normal configuration with network
Enter a choice: 1
If item 3 is selected, MS-DOS displays the following menu instead: 
MS-DOS 6 Startup Menu
=====================
1. Start Microsoft LAN Manager
2. Start Banyan VINES
Enter a choice: 1

RelatedCommands

The submenu command is one of six special CONFIG.SYS commands for defining startup menus: The other commands are:

  • The menuitem command, which defines an item on the menu.

  • The menudefault command, which specifies the default menu item.

  • The menucolor command, which defines the color of the menu's text and screen background.

  • The numlock command, which specifies the state of the NUM LOCK key when the startup menu appears. (Although numlock can be used anywhere in the CONFIG.SYS file, it is especially useful when defining a startup menu.)

  • The include command, which includes the contents of one configuration block in another. This command cannot be included in a menu block.

Subst

Associates a path with a drive letter.

The drive letter you assign represents a virtual drive, because you can use the drive letter in commands as if it were a physical drive.

Do not use the subst command when you are running Windows.

Syntax subst [drive1 : [drive2 : ]path] subst drive1 : /d

To display the names of the virtual drives in effect, use the following syntax: subst

Parameters

drive1* **:*

Specifies the virtual drive to which you want to assign a path.

drive2* **:*

Specifies the physical drive that contains the specified path (if different from the current drive).

path

Specifies the path that you want to assign to a virtual drive.

Switch

/d

Deletes a virtual drive.

Notes

Using other commands with subst

The following commands do not work, or should not be used, on drives used in the subst command:

assign

diskcomp

mirror

backup

diskcopy

restore

chkdsk

fdisk

recover

datamon

format

sys

defrag

label

 

Valid drive1 values

The drive1 parameter must be within the range specified by the lastdrive command. If not, subst displays the following error message:

Invalid parameter – drive1: 

Using subst with Microsoft Windows

Do not create or delete virtual drives using the subst command while Microsoft Windows is running. If you want to create or delete a virtual drive using the subst command, quit Windows, create or delete the virtual drive, and then start Windows again.

Using subst with compressed drives

You can use subst to associate a path on a compressed drive with a drive letter. However, the drive size and free space of the subst drive (for example, as reported by the dir command) might not match the drive size and free space reported for the compressed drive.

Example

The following command creates a virtual drive Z for the path B:\USER\BETTY\FORMS:

subst z: b:\user\betty\forms 

Now, instead of typing the full path, you can reach this directory by typing the letter of the virtual drive, followed by a colon, as in the following example:

z: 

This example works only if you have included the line lastdrive=z in your CONFIG.SYS file to define Z as the highest letter that MS-DOS recognizes as a disk drive.

Related Command

For information about increasing the number of available drive letters, see the lastdrive command.

Switches

Specifies special options in MS-DOS. Use this command only in your CONFIG.SYS file.

Syntax

switches=/w /k /n /f

Switches

/w

Specifies that the WINA20.386 file has been moved to a directory other than the root directory. You need to use this switch only if you are using Microsoft Windows 3.0 in enhanced mode and have moved the WINA20.386 file from the root directory to another directory.

/k

Forces an enhanced keyboard to behave like a conventional keyboard.

/n

Prevents you from using the F5 or F8 key to bypass startup commands.

/f

Skips the 2-second delay after displaying the "Starting MS-DOS ..." message during startup.

Notes

When to use the switches command with an enhanced keyboard

If you have a program that does not correctly interpret input from an enhanced keyboard, add this command to your CONFIG.SYS file so your enhanced keyboard will use conventional keyboard functions.

Using the /k switch with ANSI.SYS

If you use the switches=/k command and you install the ANSI.SYS device driver, use the /k switch on the device command line for ANSI.SYS.

Using the switches command with Microsoft Windows 3.0

In order for Microsoft Windows 3.0 to run in enhanced mode, the WINA20.386 file must be located in your root directory. If this file is not present, you will see this message:

You must have the file WINA20.386 in the root of your boot drive to run Windows in Enhanced Mode

If you move the WINA20.386 file, you must add the switches command with the /w switch to your CONFIG.SYS file. You must also add a device command under the [386Enh] heading in your SYSTEM.INI file, specifying the new location of the WINA20.386 file.

If you do not use Microsoft Windows version 3.0, do not use the switches command with the /w switch.

Examples

If you want MS-DOS to use conventional keyboard functions even though you are using an enhanced keyboard, add the following command to your CONFIG.SYS file:

switches=/k 

If you use Microsoft Windows 3.0 in enhanced mode and you have moved the WINA20.386 file to a directory other than the root directory, add the following command to your CONFIG.SYS file:

switches=/w 

If you want to prevent users from using the F5 or F8 key to bypass startup commands, add the following command to your CONFIG.SYS file:

switches=/n 

If you want to skip the 2-second delay after displaying the "Starting MS-DOS ..." message during startup, add the following command to your CONFIG.SYS file:

switches=/f 

You can also combine switches in one command. For example, if you want to skip the 2-second delay after displaying the "Starting MS-DOS ..." message during startup, and you use Microsoft Windows 3.0 and have moved the WINA20.386 file to a directory other than the root directory, add the following command to your CONFIG.SYS file:

switches=/f /w 

Sys

Creates a startup disk by copying hidden MS-DOS system files and the MS-DOS command interpreter (COMMAND.COM) to the disk.

The two system files (IO.SYS and MSDOS.SYS) are hidden files and do not typically appear when you type the dir command.

Syntax

sys [drive1**:][path] drive2:**

Parameters

[ drive1 :][ path ]

Specifies the location of the system files. If you do not specify a path, MS-DOS searches the root directory on the current drive for the system files.

drive2* **:*

Specifies the drive to which you want to copy the system files. These files can be copied only to a root directory, not to a subdirectory.

Notes

How the sys command copies files

The sys command copies the files in the following order: IO.SYS, MSDOS.SYS, and COMMAND.COM.

No requirement for contiguous files

MS-DOS no longer requires the two system files to be contiguous. This means that when you want to copy a new version of MS-DOS to a disk containing system files for MS-DOS version 3.3 or earlier, you need not reformat the disk.

Using the sys command on assigned drives and networks

The sys command does not work on drives that have been redirected by using the assign, join, or subst command. Sys also does not work on network drives or drives redirected using interlnk.

Examples

To copy the MS-DOS system files and command interpreter from the disk in the current drive to a disk in drive A, type the following command:

sys a: 

To copy the MS-DOS system files and command interpreter from a disk in drive B to a disk in drive A, type the following the command:

sys b: a: 

Related Commands

For information about copying files, see the copy and xcopy commands.

Time

Displays the system time or sets your computer's internal clock.

MS-DOS uses time information to update the directory whenever you create or change a file.

Syntax

time [hours**:[minutes[:seconds[.**hundredths]]][a|p]]

To display the current time or to display a prompt by which you can change the current time, use the following syntax:

time

Parameters

hours

Specifies the hour. Valid values are in the range 0 through 23.

minutes

Specifies minutes. Valid values are in the range 0 through 59.

seconds

Specifies seconds. Valid values are in the range 0 through 59.

hundredths

Specifies hundredths of a second. Valid values are in the range 0 through 99.

a|p

Specifies A.M or P.M. for the 12-hour time format. If you type a valid 12-hour time but do not type a or p, time uses a (for A.M.).

Notes

Specifying an invalid time format

If you specify the time in an invalid format, MS-DOS displays the following message and then waits for you to specify the time:

Invalid time
Enter new time:_

Changing the time format

You can change the time format by changing the country setting in your CONFIG.SYS file. For more information, see the country command. Depending on the country code, MS-DOS will display the time in the 12-hour format or the 24-hour format. If you are setting the time in the 12-hour format, be sure to specify p for hours after noon.

Ensuring that MS-DOS prompts you for the time

If you want MS-DOS to prompt you for the current time whenever you start your system, you can add the time command to your AUTOEXEC.BAT file. MS-DOS will automatically prompt you for the time and date if you do not have an AUTOEXEC.BAT file.

Example

To set your computer's clock to 1:36 P.M., use either of the following commands:

time 13:36 
time 1:36p 

Related Commands

For information about changing the current date, see the date command.

For information about changing the time format, see the country command.

Tree

Graphically displays the structure of a directory.

Syntax

tree [drive**:][path] [/f**] [/a]

Parameters

drive* **:*

Specifies the drive that contains the disk for which you want to display the directory structure.

path

Specifies the directory for which you want to display the directory structure.

Switches

/f

Displays the names of the files in each directory.

/a

Specifies that tree is to use text characters instead of graphic characters to show the lines linking subdirectories. Use this switch with character sets that do not support graphic characters and to send output to printers that don't properly interpret the graphic characters.

Note

The structure that tree displays depends upon the parameters you specify on the command line. If you do not specify a drive or path, tree displays the tree structure beginning with the current directory of the current drive.

Examples

To display the names of all the subdirectories on the disk in your current drive, type the following command:

tree \ 

To display, one screen at a time, the files in all the directories on drive C, type the following command:

tree c:\ /f | more 

To print the same list that the previous example displayed, type the following command:

tree c:\ /f > prn 

Related Command

For information about displaying the contents of a directory, see the dir command.

Type

Displays the contents of a text file.

Use the type command to view a text file without modifying it.

Syntax

type [drive**:**][path]filename

Parameters

[ drive :][ path ] filename

Specifies the location and name of the file that you want to view.

Note

If you display a binary file or a file created by a program, you may see strange characters on the screen, including formfeed characters and escape-sequence symbols. These characters represent control codes used in the binary file. In general, you should avoid using the type command to display binary files.

Examples

If you want to display the contents of a file named HOLIDAY.MAR, type the following command:

type holiday.mar 

If the file you want to display is long, you can use the more command along with type, as shown in the following command, to display the file's contents one screen at a time:

type holiday.mar | more 

Before using a pipe (|) for redirection, you should set the TEMP environment variable in your AUTOEXEC.BAT file.

Related Commands

For information about displaying filenames and file sizes, see the dir command.

For information about displaying text files one screen at a time, see the more command.

Undelete

Restores files that were previously deleted by using the del command.

Undelete offers three levels of protecting files against accidental deletion — Delete Sentry, Delete Tracker, and standard. For information about each level of protection, see Notes.

For information about the Windows version of undelete, see the chapter "Managing Your System" in the MS-DOS 6 User's Guide, or see Windows Undelete Help.

Syntax undelete [[drive : ][path]filename] [ /dt | /ds | /dos ] undelete [ /list | /all | /purge [drive]| /status | /load | /unload | /s [drive]| /t drive[-entries]]

Parameters

[ drive :][ path ] filename

Specifies the location and name of the file or set of files you want to recover. By default, undelete restores all deleted files in the current directory.

Switches

/list

Lists the deleted files that are available to be recovered, but does not recover any files. The [drive**:**][path]filename parameter and the /dt, /ds, and /dos switches control the listing produced by this switch.

/all

Recovers deleted files without prompting for confirmation on each file. Undelete uses the Delete Sentry method, if it is present. If Delete Sentry is not, undelete uses Delete Tracker, if present. Otherwise, undelete recovers files from the DOS directory, supplying a number sign (#) for the missing first character in the filename. If a duplicate filename already exists, this switch next tries each of the following characters, in the order listed, until the result is a unique filename: #%&0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.

/dos

Recovers only those files that are internally listed as deleted by MS-DOS, prompting for confirmation on each file. If a deletion-tracking file exists, this switch causes undelete to ignore it.

/dt

Recovers only those files listed in the deletion-tracking file, prompting for confirmation on each file.

/ds

Recovers only those files listed in the SENTRY directory, prompting for confirmation on each file.

/load

Loads the Undelete memory-resident program into memory using information defined in the UNDELETE.INI file. If the UNDELETE.INI file does not exist, undelete uses default values.

/unload

Unloads the memory-resident portion of the Undelete program from memory, turning off the capability to restore deleted files.

/purge[ drive ]

Deletes the contents of the SENTRY directory. If no drive is specified, undelete searches the current drive for the directory.

/status

Displays the type of delete protection in effect for each drive.

/s[ drive ]

Enables the Delete Sentry level of protection and loads the memory-resident portion of the undelete program. The program records information used to recover deleted files on the specified drive. If you do not specify a drive, using this switch enables the Delete Sentry level of protection on the current drive. Specifying the /s switch loads the memory-resident program into memory using the information defined in the UNDELETE.INI file.

/t drive [- entries ]

Enables the Delete Tracker level of protection and loads the memory-resident portion of the undelete program. The program records information used to recover deleted files. The required drive parameter specifies the drive containing the disk for which you want undelete to save information about deleted files. The optional entries parameter, which must be a value in the range 1 through 999, specifies the maximum number of entries in the deletion-tracking file (PCTRACKR.DEL). The default value for entries depends upon the type of disk being tracked. The following list shows each disk size, its default number of entries, and its corresponding file size:

Disk size

Entries

File size

360K

25

5K

720K

50

9K

1.2 MB

75

14K

1.44 MB

75

14K

20 MB

101

18K

32 MB

202

36K

32 MB

303

55K

Caution: Do not use deletion tracking for any drive that has been redirected by using the join or subst command. If you intend to use the assign command, you must do so before using undelete to install deletion tracking.

Notes

Caution: Once you delete a file from your disk, you may not be able retrieve it. Although the undelete command can recover deleted files, it can do so with certainty only if no other files have been created or changed on the disk. If you accidentally delete a file that you want to keep, stop what you are doing and immediately use the undelete command to retrieve the file.

Levels of protection

MS-DOS provides three levels of protection against accidental file deletion — Delete Sentry, Delete Tracker, and standard.

Delete Sentry provides the highest level of protection. Delete Sentry requires a small amount of memory and disk space. The next level of protection is Delete Tracker, which requires the same amount of memory as Delete Sentry, but minimal disk space. The lowest level of protection, standard, requires neither memory nor disk space, but still allows you to recover deleted files, provided that their location on the disk has not been taken by other files.

For more details, see the notes that follow about each level of protection.

Delete Sentry

Delete Sentry provides the highest level of protection to ensure that you can recover deleted files. This level of protection creates a hidden directory named SENTRY. When you delete a file, undelete moves the file from its current location to the SENTRY directory without changing the record of the file's location in the file allocation table (FAT). If you undelete the file, MS-DOS moves the file back to its original location.

The size of the SENTRY directory and its files is limited to approximately 7 percent of your hard disk space. If you delete a file and the directory and its files exceed this limit, undelete purges the oldest files until enough space has been freed to accommodate the newly deleted file.

In addition to the disk space needed for the SENTRY directory, Delete Sentry requires 13.5K of memory for the memory-resident portion of the undelete program.

Delete Tracker

Delete Tracker provides an intermediate level of protection. It uses a hidden file named PCTRACKER.DEL to record the location of deleted files. When you delete a file, MS-DOS changes the file allocation table (FAT) to indicate that the location of the file is now available for another file. You can recover the deleted file provided that another file has not been placed in that location. If another file has been placed there, you may be able to partially recover the deleted file.

Delete Tracker requires 13.5K of memory for the memory-resident portion of the undelete program and a minimal amount of disk space for the PCTRACKER.DEL file.

Standard

The standard level of protection is automatically available when you switch on your computer. Of the three levels of guarding against accidental file deletion, it provides the lowest level of protection. However, it does not require you to load a memory-resident program. It also has the advantage of requiring neither memory nor disk space.

Using this level of protection, you can recover a deleted file, provided MS-DOS has not placed another file in the deleted file's location. If a file has been placed there, you may be unable to recover all or part of the deleted file.

Method used to recover files

Use any one of the following switches: /dos, /dt, or /ds. If you do not specify a switch, undelete uses Delete Sentry, if it is available. If Delete Sentry is not available, undelete uses the Delete Tracker file, if available. If a deletion-tracking file is not available, undelete attempts to recover files by using MS-DOS.

Caution Undelete cannot restore a directory that has been removed, and it cannot retrieve a file if you have removed the directory that contained the file. If the directory was an immediate subdirectory of the root directory, you may be able to retrieve the directory and its files if you first use the unformat command to restore the directory and then use undelete to retrieve the files. You must use caution because you can lose data if you use unformat incorrectly. Usually, unformat can restore only immediate subdirectories of the root directory. However, when you use unformat to recover an accidentally formatted disk, unformat recovers all root-level files and subdirectory names.

The UNDELETE.INI file

Undelete uses the UNDELETE.INI file to define values when undelete is loaded into memory. If the file does not exist when you load undelete into memory, undelete creates an UNDELETE.INI file that contains the following values:

  • Use the Delete Sentry method of file tracking on the current drive.

  • Save all files except *.TMP, *.VM?, *.WOA, *.SWP, *.SPL, *.RMG, *.IMG, *.THM, and *.DOV files.

  • Do not save files that have the archive bit set.

  • Purge files after 7 days.

  • Restrict the amount of disk space available for deleted files to 20 percent of total disk space.

The UNDELETE.INI file has five sections: [sentry.drives], [sentry.files], [mirror.drives], [configuration], and [defaults].

The [sentry.drives] section specifies the drives protected by the Delete Sentry method, if used.

The [sentry.files] section specifies the files protected from deletion using either Delete Tracker or Delete Sentry. A hypen (-) before a filename indicates that the file is not saved. The default values defined in the [sentry.files] section are as follows:

[sentry.files]
*.* -*.TMP -*.VM? -*.WOA -*.SWP -*.SPL  -*.RMG -*.IMG -*.THM -*.DOV

The [mirror.drives] section specifies the drives protected by the Delete Tracker method, if used.

The [configuration] section defines the following values:

  • Whether files with the archive bit set are protected. If files with the archive bit set are not protected (the default value), the entry is as follows:
    archive=FALSE
A TRUE value saves files with the archive bit set. 
  • The number of days files are saved. The following entry defines the default value:
    days=7
  • The amount of total disk space reserved for deleted files. The following entry defines the default value:
    percentage=20

The [defaults] section specifies the method of file tracking. The following defines the default Delete Sentry method:

[defaults]
d.sentry=TRUE
d.tracker=FALSE

Changing the method of file protection

You can use only one method of file protection at a time. If you want to change the method, carry out the following procedure:

  1. Unload the memory-resident portion of the Undelete program by typing the following at the command prompt:

undelete /u

  1. Enable the new level of protection and reload the memory-resident portion of the Undelete program. For example, to enable the Delete Sentry level of protection on your current drive, type the following at the command prompt:

undelete /s

Drives protected

The Undelete program protects all drives specified in the UNDELETE.INI file, regardless of the drives you specify when you start the program. For example, suppose your UNDELETE.INI file contains the following entry:

[sentry.drives]
C=
D=

The following command enables the Delete Sentry level of protection on both drives C and D:

undelete /sc 

To enable protection only on drive C, you would do the following:

  1. Using any text editor, open your UNDELETE.INI file.

  2. Delete the following line from the [sentry.drives] section of the file:

    D=
    
  1. Save changes you made to the file.

  2. Exit your text editor.

  3. Enable Delete Sentry protection by typing the following at the command line:

    undelete /sc
    

Network drives and delete protection

To protect files on a network drive from accidental deletion, you must enable the Delete Sentry level of protection and have read, write, create, and delete file access in the drive's root directory.

Examples

The following command specifies that undelete is to recover all deleted files in the current directory one at a time, to prompt for confirmation on each file, and to use the highest available level of delete tracking:

undelete 

The following command specifies that undelete is to recover all deleted files with the .BAT extension in the root directory of drive C, without prompting for confirmation on each file:

undelete c:\*.bat /all 

The following command loads the memory-resident portion of the undelete program into memory, creates a hidden directory named SENTRY, and specifies that undelete move files you delete on drive C to that directory:

undelete /sc 

The following command loads the memory-resident portion of the undelete program into memory and creates a PCTRACKER.DEL file to track up to 400 deleted files on drive C:

undelete /tc-400 

Unformat

Restores a disk that was erased by using the format command.

Unformat restores only local hard disk drives and floppy disk drives; it cannot be used on network drives. The unformat command can also rebuild a corrupted disk partition table on a hard disk drive.

Syntax

unformat drive : [/l] [/test] [/p]

Parameters

drive* **:*

Specifies the drive that contains the disk on which you want to recover files.

Switches

/l

Lists every file and subdirectory found by unformat. If you do not specify this switch, unformat lists only subdirectories and files that are fragmented. To suspend scrolling of the displayed list, press CTRL+S; to resume scrolling, press any key.

/test

Shows how unformat would recreate the information on the disk, but does not actually unformat the disk.

/p

Sends output messages to the printer connected to LPT1.

Notes

Limitation on the unformat command

If the format command was used with the /u switch, unformat cannot restore the disk to its previous condition.

Unformatting a disk

The unformat command can restore your disk by using information in the root directory and file allocation table on the disk.

As unformat rebuilds the disk, it displays how many subdirectories it has found; if you specified the /l switch, it also shows you all files in each subdirectory.

If unformat finds a file that appears to be fragmented (that is, stored in separate places on the disk), it cannot recover the file because it cannot locate the remaining portions of the file. In this case, the unformat command prompts you to confirm whether you want unformat to truncate the file (that is, recover only the first part of the file that it can locate) or delete the file altogether.

If unformat does not prompt you for a specific file, that file is most likely intact. In certain circumstances, however, unformat may not recognize that a file is fragmented, even though it has located only a portion of the file. If this happens to a program file, the program does not run properly. If this happens to a data file, information is lost and the program that created the data file may not be able to read it. In these cases, your only recourse is to restore the files from your original floppy disks or backup files.

Sector size of the hard disk

The sectors on your hard disk must be 512, 1024, or 2048 bytes.

Examples

To determine whether unformat can restore a formatted disk in drive A, type the following command:

unformat a: /test 

To restore a formatted disk in drive A, listing all files and subdirectories, type the following command:

unformat a: /l 

Related Command

For information about formatting a disk, see the format command.

Ver

Displays the MS-DOS version number.

Syntax

ver

Example

When you enter the ver command, MS-DOS displays the following message:

MS-DOS Version 6.0 

Verify

Directs MS-DOS to verify that your files are written correctly to a disk and displays the status of verification. For example, you can use this command to make sure data is not written to a bad sector. You can use this command either at the command prompt or in your CONFIG.SYS file.

Syntax

verify [on|off]

Switch

on|off

Specifies whether MS-DOS should verify (on) or not verify (off) that write operations are done correctly.

Notes

Displaying the current status of the on|off switch

Use the verify command without a switch to find out whether verification is turned on.

How verify affects performance

Turning verify on slows down all disk write operations.

Related Commands

For information about checking a disk for bad sectors, see the chkdsk command.

For information about verifying files as you copy them, see the /v switch in the copy or xcopy command.

Vol

Displays the disk volume label and serial number, if the disk has them.

Syntax

vol [drive**:**]

Parameters

drive* **:*

Specifies the drive that contains the disk for which you want to display the volume label and serial number.

Note

To cause MS-DOS to display the volume label of the disk in the current drive, you can use the vol command with no parameter.

Related Commands

For information about assigning a volume label, see the format and label commands.

VSafe

Continuously monitors your computer for viruses and displays a warning when it finds one. VSafe is a memory-resident program that uses 22K of memory.

Do not use the vsafe command when you are running Windows.

Syntax

vsafe [/option[+ | –] ...] [/ne] [/nx ] [/ax | /cx] [/n] [/d] [/u]

Switches

option

Specifies how VSafe monitors for viruses. Use a plus or minus sign (+ or –) after the number to turn an option on or off. The following list describes the options you can choose.

1

Warns of formatting that could completely erase the hard disk. The default setting is "on."

2

Warns of an attempt by a program to stay in memory. The default setting is "off."

3

Prevents programs from writing to disk. The default setting is "off."

4

Checks executable files that MS-DOS opens. The default setting is "on."

5

Checks all disks for boot sector viruses. The default setting is "on."

6

Warns of attempts to write to the boot sector or partition table of the hard disk. The default setting is "on."

7

Warns of attempts to write to the boot sector of a floppy disk. The default setting is "off."

8

Warns of attempts to modify executable files. The default setting is "off."

/ne

Prevents VSafe from loading into expanded memory.

/nx

Prevents VSafe from loading into extended memory.

/a x

Sets the hot key as ALT plus the key specified by x.

/c x

Sets the hot key as CTRL plus the key specified by x.

/n

Allows VSafe to monitor for possible viruses on network drives.

/d

Turns off checksumming.

/u

Removes VSafe from memory.

Note

Before installing Windows, turn off VSafe. If VSafe is running, you may not be able complete the Windows installation. If you use VSafe with Windows, run the MWAVTSR.EXE memory-resident program by adding the following command to your WIN.INI file:

load=mwavtsr.exe 

MWAVTSR.EXE enables VSafe messages to be displayed in Windows.

Example

To specify that VSafe not check for formatting that could erase all data on the hard disk, that VSafe warn of attempts to write to the boot sector of a floppy disk, and that ALT+T be assigned as the hot key to display the VSafe screen, type the following command:

vsafe /1- /7+ /At 

Xcopy

Copies directories, their subdirectories, and files (except hidden and system files).

With this command, you can copy all the files in a directory, including the files in the subdirectories of that directory.

Syntax

xcopy source [destination] [/a|/m] [/d:date] [/p] [/s [/e]] [/v] [/w]

Parameters

source

Specifies the location and names of the files you want to copy. Source must include either a drive or a path.

destination

Specifies the destination of the files you want to copy. Destination can include a drive letter and colon, a directory name, a filename, or a combination.

Switches

/a

Copies only source files that have their archive file attributes set. This switch does not modify the archive file attribute of the source file. For information about how to set the archive file attribute, see the attrib command.

/m

Copies source files that have their archive file attributes set. Unlike the /a switch, the /m switch turns off archive file attributes in the files specified in source. For information about how to set the archive file attribute, see the attrib command.

/d: date

Copies only source files modified on or after the specified date. Note that the format of date depends on the country setting you are using.

/p

Prompts you to confirm whether you want to create each destination file.

/s

Copies directories and subdirectories, unless they are empty. If you omit this switch, xcopy works within a single directory.

/e

Copies any subdirectories, even if they are empty. You must use the /s switch with this switch.

/v

Verifies each file as it is written to the destination file to make sure that the destination files are identical to the source files.

/w

Displays the following message and waits for your response before starting to copy files:

Press any key to begin copying file(s)

Notes

Default value for destination

If you omit destination, the xcopy command copies the files to the current directory.

Specifying whether destination is a file or directory

If destination does not contain an existing directory and does not end with a backslash (\), xcopy prompts you with a message in the following format:

Does destination specify a file name
or directory name on the target
(F = file, D = directory)?

Press F if you want the file(s) to be copied to a file. Press D if you want the file(s) to be copied to a directory.

Xcopy does not copy hidden and system files

In older versions of MS-DOS, xcopy copies hidden and system files. This is not the case in MS-DOS 6. To remove the hidden or system attribute from a file, use the attrib command.

Xcopy sets archive attribute for destination files

Xcopy creates files with the archive attribute set, whether or not this attribute was set in the source file. For more information about file attributes, see the attrib command.

Xcopy vs. diskcopy

If you have a disk that contains files in subdirectories and you want to copy it to a disk that has a different format, you should use the xcopy command instead of diskcopy. Since the diskcopy command copies disks track by track, it requires that your source and destination disks have the same format. Xcopy has no such requirement. In general, use xcopy unless you need a complete disk image copy. However, xcopy will not copy hidden or system files such as IO.SYS and MSDOS.SYS. Therefore, use diskcopy to make copies of system disks.

Xcopy exit codes

The following list shows each exit code and a brief description of its meaning:

0

Files were copied without error.

1

No files were found to copy.

2

The user pressed CTRL+C to terminate xcopy.

4

Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.

5

Disk write error occurred.

You can use the errorlevel parameter on the if command line in a batch program to process exit codes returned by xcopy. For more information, see Examples.

The following example copies all the files and subdirectories (including any empty subdirectories) from the disk in drive A to the disk in drive B:

xcopy a: b: /s /e 

The following example uses the /d: and /v switches:

xcopy a: b: /d:01/18/93 /s /v 

In this example, only files on the disk in drive A that were written on or after 01/18/93 are copied to the disk in drive B. Once the files are written to the disk in drive B, the xcopy command compares the files on the two disks to make sure they are the same.

You can create a batch program to perform xcopy operations and use the batch if command to process the exit code in case an error occurs. For example, the following batch program uses replaceable parameters for the xcopy source and destination parameters:

\@echo off
rem COPYIT.BAT transfers all source
rem files in all directories on the source
rem drive (\%1) to the destination drive (\%2)
xcopy \%1 \%2 /s /e
if errorlevel 4 goto lowmemory
if errorlevel 2 goto abort
if errorlevel 0 goto exit\:lowmemory
echo Insufficient memory to copy files or
echo invalid drive or command-line syntax.
goto exit\:abort
echo You pressed CTRL+C to end the copy operation.
goto exit\:exit

To use this batch program to copy all files in the C:\PRGMCODE directory and its subdirectories to drive B, type the following command:

copyit c:\prgmcode b: 

The command interpreter substitutes C:\PRGMCODE for %1 and B: for %2, then uses xcopy with the /e and /s switches. If xcopy encounters an error, the batch program reads the exit code and goes to the label indicated in the appropriate if errorlevel statement. MS-DOS displays the appropriate message and exits from the batch program.

Related Command

For information about copying individual files, see the copy command. For information about copying disks, see the diskcopy command.