MS-DOS Prompt


Better Dir Command
Do you know that DIR command can be adjusted? Try to type the following command into MS-DOS prompt, and then press Enter:

Set dircmd=/o:parameters /a

Change the parameters with one of these parameters:
N ? sort by file name
E ? sort by file extension
D ? sort by file date
S ? sort by file size
A ? sort by last accessed date
G ? list the folder first
Then try to type DIR command as usual.

For example, to list the folder first and then sort all by its name, use this command:
Set dircmd=/o:GND /a

To reverse the sort order (from Z to A), use a minus sign before the parameter, like this:
Set dircmd=/o:-N /a

Another example:
Set dircmd=/p

Now every time you execute the DIR command, the report list will be displayed page by page with the Enter pressing.

If you don't want to type the set dircmd command for every MS-DOS session, then insert that line command in the C:\Autoexec.bat file.

Change the DOS Prompt Symbol
You can change the DOS prompt symbol from C:> to other symbols by typing this commands:

PROMPT [text]

text could be a normal character or these special characters:
$Q = symbol
$$ $ Symbol
$T Current time
$D Current date
$P Current drive and path
$V Windows version number
$N Current drive
$G > symbol
$L < symbol
$B | symbol
$H Backspace
$E Escape
$_ Empty

Type the commands ( for example prompt $D$_$P$B ) in the Batch file column at the Program tab of the MS-DOS Prompt Properties dialog box.

Change Your Files Date
If you look at several files that produced by various software companies, you can see that all files have a similar time and date properties. You can do the same to your files, just follow these steps:

Double-click on the clock at Windows 9X/Me Taskbar, and then adjust it to a new time and date. For example January 1, 2000, 00:00. Click OK. Open the MS DOS prompt window, and then go to the folder that you want to change its date and time. Type a copy command by using this format: COPY /B filename+,,

For example if your file name is document.txt, then you must type

COPY /B document.txt+,,

Type Y at the confirmation box. Now you can check your files date and time by using the DIR command.

Checking the Partitioning Status
Microsoft MS-DOS FDISK has a parameter that causes it to display the partition status automatically. To check the partitioning status, type the following at the MS DOS prompt:

C:\>fdisk /status

This command provides information similar to that found by selecting option 4, Display Partition Information, from the FDISK Options menu.

Command.com Hidden Parameters
COMMAND /D

Used on the Config.sys SHELL= line, or at the MS-DOS prompt, to prevent the execution of the Autoexec.bat file when booting. Example: SHELL=C:\COMMAND.COM C:\ /E:512 /D /P

COMMAND /Z

Used to display the "ERRORLEVEL" return code messages after executing each external DOS command. This switch can be used on the Config.sys file SHELL= line. Example: SHELL=C:\COMMAND.COM C:\ /E:512 /P /Z

Creating a Macro using Doskey
You can find Doskey feature in the MS-DOS prompt. This feature can create a macro that makes it possible to redefine the other MS-DOS commands. For example, if you want to redefine the Mem command so it can stop the screen after one page, add these following commands into the Autoexec.bat file:

c:\Windows\Command\Doskey

Doskey mem=mem.exe $* /p

The $* characters means include any parameter after the Mem command.

If you often open a folder named Database, it is unnecessary always to type "cd database" in the command prompt. As a replacement, add these following commands into the Autoexec.bat file:

c:\Windows\Command\Doskey

doskey d=cd database

From now on, to enter the database folders, all you must do is type "d" (without quotation mark) in the command prompt, and then press Enter.

DIR Hidden Parameters
The DIR command has a useful hidden parameter. If you type DIR/Z, the file name list will appears on the screen and hide their long file name. If you type DIR /B you will only see the long file name. Meanwhile, if you type DIR /Z/B you will only see the short file name.

Extra DOS Menus
Anytime you open an MS-DOS window under Windows, a DOS icon appears in the upper-left corner of the window. Click the icon, and a menu of commands appears. Did you know that all these commands are accessible from the Taskbar as well? Right-click the MS-DOS item there, and the same menu appears.

FDisk Hidden Parameters
FDISK /FPRMT

Enables the use of FAT32 file system on hard drives smaller than 512 MB. Normally not allowed by default.

FDISK x /PRI:ps /EXT:es /LOG:ls

x = drive number (1, 2, 3... etc.). Drive #1 corresponds to the 1st hard disk installed on your machine (C, D, E... etc.)
/PRI:ps ? creates a primary partition of size... (in megabytes).
/EXT:es ? creates an extended partition of size... (in megabytes).
/LOG:ls ? creates a logical drive in the extended partition of size... (in megabytes).
FDISK /MBR

Repairs a damaged boot sector by overwriting it with a fresh copy (writes a new Master Boot Record to the hard disk without altering the partition table information).

Format.com Hidden Parameters
FORMAT drive: /AUTOTEST

Checks the existing format of your disk, and then proceeds with an unattended disk format. It does not prompt for a volume label, it does not prompt to format another disk, no delay, no user intervention, ends without pausing, and displays disk space statistics after completion.

FORMAT drive: /BACKUP

This parameter works exactly like /AUTOTEST, but it does prompt the user for a volume label, and it does display disk space information upon completion.

FORMAT drive: /SELECT

This parameter is similar to using the MIRROR command (MS-DOS 5.0 and earlier only).

FORMAT drive: /U

This parameter performs an unconditional format, which destroys every byte of data on a disk by overwriting it with hex F6h. You cannot unformat a disk formatted using the /U option.

FORMAT drive: /SELECT /U

This particular combination of format.com parameters makes a disk. Do not use these two format switches together on any drive!

FORMAT drive: /Z:n

Formats a FAT32 drive with a cluster size of n times 512 bytes. Meaning:

drive: = your hard drive letter (C:, D:, E:... etc).

n = number of sectors per cluster multiplied by 512 (cluster size in bytes).

Examples:
n ? 1 creates a 512 bytes cluster;
n ? 2 creates a 1024 bytes (1 KB) cluster;
n ? ? creates a ? x 512 = ???? bytes (???? bytes : 1024 = ? KB) cluster.

You can modify the size of the allocation units (sectors) on a FAT32 drive to your heart's desire.

Loading the Mouse Driver
When you restart Windows 98/95 to MS DOS mode (by clicking the Start-Shut Down-Restart the computer in MS-DOS mode? menus), then your mouse cannot be used anymore. To solve this problem, usually you have to load the mouse driver using Autoexec.bat file. Unfortunately, this method wastes your memory when you are using Windows 98/95, since the mouse driver is no longer needed in the Windows mode.

Actually, an alternative is to write the load commands into the DOSSTART.BAT file. You'll find this file in the C:\Windows file. Alternatively, you can create it by yourself using Notepad.

Mem.exe Hidden Parameters
MEM /A
Displays a short summary screen of your memory configuration and the status of the HMA. HMA (High Memory Area) is a little known 64 KB area just above the first megabyte (1 MB = 1,024 KB = 1,048,576 Bytes) of RAM mapped by MS-DOS HIMEM.SYS memory manager (or another 3rd party high/extended/expanded memory manager, like Quarterdeck QEMM386, Helix NetRoom RM386, IBM 386MAX, etc). Parts of DOS module itself and of MS-DOS BUFFERS usually load into the HMA. Example of MEM /A output display (only the HMA info is shown here):

"Available space in High Memory Area 1K (944 bytes) MS-DOS is resident in the high memory area."

To display all available memory configurations at a DOS prompt, run:

MEM /A /C /P
Alternatively, if you prefer technical details (conventional/upper memory regions map and exact hex addresses where all loaded devices/drivers/TSRs reside), run:

MEM /D /P
NOTICE: High DOS is enabled by this CONFIG.SYS line (the "HIGH" switch): DOS=HIGH,UMB

More Benefit From the Set Command
Add the set copycmd=/y command in the C:\Autoexec.bat file. From now on, every time you execute the copy, move, or xcopy commands, the file with a same name will be overwritten without any warning. To go back to the default condition, you can type set copycmd=/-y command.

Add the set dircmd=/w /-e command in the C:\Autoexec.bat file. From now on, every time you execute the Dir command, the file name list will be sorted from Z to A, and appeared in the wide style. If you want, you can change /w and /-e parameters with other dir parameters. Type dir/? to read a full listing of the Dir command.

More Efficient with Subst
The SUBST.EXE command makes it possible to treat a directory as a drive. Therefore, a long directory name can be shorten to just a drive letter (C:, D:, E:, etc). For example, type this command at MS DOS prompt:

subst e: c:\data\2000\april\report

From now on, every time you want to open that folder, you only have to type cd e: . To find out all subst parameters type subst /? at the MS DOS command prompt.

Open a Folder Window from the Prompt
To see/open the active folder windows in the MS-DOS prompt, just type START . (start space dot). To open the main folder just type START .. (start space two-dots)

You can also type the full path of the folder, like this:
Start "C:\Windows\Start Menu"

The quotes only needed if there are folder or file names that separated by a space.

Pipe (|) Character
Type dir /s | more in the command prompt, and then press Enter to show all folders one screen at a time. Alternatively, type dir /s /o | more to sort all folders in alphabetical order.

If you want to see contents of a document one screen at a time, type this command:

type document.txt | more.

If you want to switch to the Programs folder and then run application.exe, use this command:

cd program | application.

Quick Changing Folder
Open the MS-DOS prompt window by clicking the Start button, Programs, and MS-DOS Prompt. Open Windows Explorer, go to the folder that you want, and then type cd in the DOS prompt window. Press the spacebar to insert a space. Click and drag the icon of selected folder, from Explorer screen to the DOS prompt window. The name of the folder will be showed in the DOS prompt window. Press Enter to go to that folder.

Renaming the Long File Name
How to rename a long file name from MS DOS mode? As you know, MS-DOS prompt only can show 8-characters file names.

You have a long file name document, for example March - Monthly Expenses Report.doc. And then you want to change its name to April - Monthly Expenses Report.doc. In the MS-DOS prompt type:

ren "March*.doc" "April*.doc "

Meanwhile, if you want to change March - Monthly Expenses Report.doc to March - Monthly Sales Report.doc, in the MS DOS prompt type:

ren "*Expenses.doc" " *Sales.doc"

Restoring Deleted Files
Don't panic if your very important document accidentally deleted and removed from the Recycle Bin. If you upgrade your system from MS-DOS and still have a DOS utility named undelete.exe, follow these steps to save your documents:

Click the Start button, Shut Down, select "Restart the computer in MS-DOS mode," and then click Yes. Reboot to the DOS mode, go to the folder that contains the deleted documents. Type lock c: and then press Enter. Type Y and then press Enter at the confirmation.

Type undelete, then press Enter. Follow the prompt to get your document back. After returns to the DOS prompt, type unlock c: to avoid direct access to the disk. Finally, type exit to returns to Windows.

Restoring the DOS Icon
Are you accidentally deleting the MS-DOS prompt icon? It is very simple to solve this problem. Right click at the Start button, and then choose Open or Explore. Open the Programs folder, right click at the empty space, and then select New-Shortcut. Type command.com at the Command line column, click Next, and then Finish. By using the same method, you can create a shortcut to MS-DOS prompt at desktop.

Separating Long File Names
How to separate several files with long file names from a folder that has short file names? Use 9 questions marks followed by *.* would move ONLY the file names that had more than 8 characters, leaving behind only the files that were named with the 8.3 short file names. Here is the command:

Move C:\Source\?????????*.* C:\destination

Shortcut for DOS Commands
Want to access DOS command quickly? Just follow these steps:
1. Click on Start - Run, type sysedit and then click OK to open System Editor window.
2. Add this line to Config.sys file:
Device=c:\windows\command\ansi.sys
3. Save the changes and then close System Editor window. Reboot your Windows 9X/Me.
4. Run Notepad, and then type this two lines text:
Prompt $e[%1;%2;"%3 %4 %5 %6 %7 %8 %9";13p
Prompt $n$g
5. Save that file as Command1.bat
6. For example, you want to use Shift+F1 to execute DIR C: command. Look at the table below that the code for Shift+F1 is 0 84. Open MS-DOS window, and type this on MS-DOS prompt:
Command1 0 84 DIR C:
7. Press Enter to execute that command.

Starting from now on, you can press Shift+F1 to execute DIR C: as long as you don't shutdown the computer.

Here are ASCII code number for function buttons
Shift Ctrl Alt
F1 0 84 0 94 0 104
F2 0 85 0 95 0 105
F3 0 86 0 96 0 106
F4 0 87 0 97 0 107
F5 0 88 0 9X/Me 0 108
F6 0 89 0 99 0 109
F7 0 90 0 100 0 110
F8 0 91 0 101 0 111
F9 0 92 0 102 0 112
F10 0 93 0 103 0 113
F11 0 135 0 137 0 139
F12 0 136 0 138 0 140

Repeat steps 4 - 7 to make similar batch files, and name it Command2.bat, Command3.bat, etc. Associate it with different DOS commands. If you want the commands always available after computer rebooting, just call those batch files from C:\Autoexec.bat file (use System Editor to do it).

Useful Copy Commands
You can use the copy command to print several text files at a time. To do so, open the MS-DOS prompt, go to your documents folder and then type copy *.txt lpt1 (if your printer connected with lpt1).

To check a document from any disk errors, type copy document.txt nul and press Enter.

Useful Keys at DOS Mode
You can use several keys on the MS-DOS Prompt. These keys will help you to get faster editing process.

(Key : Function)
F1 or Right arrow : Call the last commands, letter by letter.
F2+letter : Call the last commands, until the last typed letter.
F3 : Call all of the last commands.
F4+ letter : Reverse the F2 keys job, delete all letters after the last typed letter.
F6 : Get the Ctrl+Z character that used to finish a batch file.
Backspace or Ctrl+H or Left arrow : Step back, also delete the previous letter.
Ctrl+C : Cancel commands.
Ctrl+P : Sending output from command to printer.

Example:
Previously you have typed dir windows /p command, and then press Enter. Now you can press F2 and N, and automatically you will get dir wi

Ver Hidden Parameters
VER /R

VER is an internal (built-in) MS-DOS command (an actual file does not exist). VER /R displays extended DOS info: the DOS revision and the memory location of the DOS module, in addition to using the plain VER command.

With Start and Without Start
When you load an application with the Start facility, it will be opened in a new MS-DOS prompt window. Here is the illustration with Xcopy command:

Open MS-DOS window and move to C:\ folder. Type md c:\test and then press Enter to make the new folder. Now type xcopy c:\data c:\tes and press Enter. Xcopy will copy the data from C:\Data to C:\Test.

Now use the Start command. Type Start xcopy c:\data c:\tes and press Enter. This time xcopy will be executed in a new MS-DOS window. You can use the first MS-DOS window for the next task.

Rename Multiple Files through DOS Prompt
To change, for example, all the .TXT files to names that end in .DOC, normally you have to right-click on them one at a time and type the new names. What a waste time since you can do that in a second. Simply double-click on the DOS icon, in MS DOS prompt use this command followed by Enter:

ren *.txt *.doc

Same DOS Directory All The Time
Always open a DOS window in the same directory? Now you can do that faster than ever. Right-click the MS-DOS icon and choose Properties. Click the Program tab. On the Working line, type the directory you want to use. Click OK.

Automate Opening a Specific Folder
If you frequently open a specific folder as a DOS directory, now you can automate the process by placing a shortcut in the Windows folder. To do so, create a new shortcut by right clicking on the Desktop. In the Command line field, type "command" (without the quotes) and in the name field, type Open Directory. Once the shortcut is created, right-click on it, select Properties, click on the Program tab, and type the path for the DOS directory you want to open in the Working field. For example, type \Windows\Favorites to open the Favorites folder. If you'd like to see a file listing whenever you run the shortcut, type dir /p in the Batch file field.

Determine Wasted Space without FAT 32
Want to know how much space you have wasted since you do not want to convert your old FAT 16 to FAT 32?.

Click Start, Programs, MS-DOS Prompt. At the DOS prompt, type cd\ and press Enter. Now type dir /a/s/v and press Enter. The difference between the value for Bytes and the value for Bytes Allocated is the amount of space not used by the files, but allocated to the clusters that store those flies. Subtract Bytes from Bytes Allocated to determine your wasted space.

Easily Hide the MS-DOS Window Toolbar
When you are working in an MS-DOS Prompt window, you can easily hide the MS-DOS toolbar. Simply press Alt + Spacebar, when the context menu appears, click on Toolbar. To display the toolbar, press Alt + Spacebar, and then click on Toolbar again.

Saving CHKDSK Result
Never heard about CHKDSK? It is a small utility in MS-DOS to check your disk integrity. You can easily save the CHKDSK results to a text file, by entering this command MS-DOS Prompt, followed by Enter:

chkdsk > result.txt

Using this method you won't see anything happening while CHKDSK works, since all the data is going into your new file. To view the file, type following command followed by Enter:
Notepad result.txt

If you prefer a more readable file name, you can add quotes. For example:
chkdsk > "result September p;2000.txt"

Checking Your Working Path
Unsuccessfully attempt to run a program from the Command Prompt? The program may not be in the path. In this case, all you have to do is type "set" (without the quotes) and press Enter. Windows will display all the environment variables. If the list is too long to fit in one screen, type set|more and press Enter. The More command will cause the display to pause at the end of each page of information. To continue to another page, press Space.

Keep The Read-Only Attributes
Have you noticed that if you use Xcopy to copy files from a CD-ROM to a hard disk or a floppy, the read-only attributes are stripped. To keep those attributes on the copied files, go to the Command Prompt and type xcopy (your folder) /k and press Enter. The read-only attribute will now be active on the copied files.

Printing a Folder List
If you want to print a list of all files in a folder, and also list the files in the sub-folders which belong to the folder, add the /S switch to the command line in the MS DOS prompt:

dir c:\abcfiles\*.* /s > c:\abcfiles.txt

which not only lists the files and sub-folders in \abcfiles, but also continues to list the files in all the sub-folders. You can then read it using NotePad or WorPad if the file size getting bigger.

Bonus tip:
If you have Microsoft Outlook installed on your system, then you can get a better list. From the Outlook Bar, click on My Computer. If there is no shortcut to My Computer, you can create it by right click an empty Space in the Outlook Bar, choose Outlook Bar Shortcut, Look in – File system, and click OK. Now expand the folder and subfolder, which you want to print. Click on File – Print menu, adjust your page, and then print the result.

Quickly Deleting a Floppy
Want to quickly deleting a floppy disk contents? Open Notepad and then type the following batch commands:

@echo off
attrib -h A:\*.*
deltree /y A:\*.* > NUL
echo BLANK|label A:

Name it Delete A.bat (or any name as long as the extension is bat) and save it on your desktop (C:\Windows\Desktop).

Now you can insert a floppy into A: drive and execute the batch files by double click on it. It is faster than formatting the floppy.

Note: The symbol between the "BLANK" and "label" in the last line is the pipe symbol, two short vertical lines you can find on your keyboards with the backslash key.

MS-DOS in Full Screen Mode
If you are using the MS-DOS dialog box in full-screen mode all of the time, then right click its shortcut on the Start Menu and choose Properties. Click the Screen tab. Under Usage, select Full Screen and click OK to save your settings. Now your MS-DOS dialog box will run full-screen automatically. To get back into you Windows, type exit in the command prompt and press Enter.

If you have any MS DOS applications or games, then you can apply the same method to open it in full screen mode. Just create a shortcut for the application in your desktop or Start menu, and then change its properties as described above.