Labels

MS-DOS and Windows command line tips







Drag and drop to the command line

When working with files with a long file path instead of typing the full path drag-and-drop a file into the command line. For example, if you needed to copy the picture.gif file from E:\Computer Hope\long path\tips\examples\images directory you could open that folder in Windows Explorer and drag and drop the file into the command line to have "E:\Computer Hope\long path\tips\examples\images\picture.gif" entered into the command line.

Note: This tip does not work in Windows Vista.

Tip: If you're having difficulty with the path being copied in Windows 7, make sure you're running the command line as Administrator.

View Windows command line history

While in the Windows command line, press the F7 key to view a history of all the commands that have been entered in that window. Below is a picture of what the Windows command line history box will look like when open.

Windows command line history


Pressing the up or down keys will allow you to browse through all commands and once highlighted pressing enter will perform the previous command.


Open web page from Windows command line

Use the below start command to open a web page from the command line. For example, the below command would open the Computer Hope web page from the command line.



Open Windows explorer for the current Windows command line directory

Use the below start command to open Windows Explorer window for the current directory you're viewing in the Windows command line. For example, if you were in the C:\Windows> directory, typing in the below command would open the Windows folder in Windows Explorer.

start .

Bonus tip: The period is for the current directory, if you were to type in two periods (start ..) it would open the parent directory.


Clear the clipboard through the command line

Clear anything in the Windows clipboard using the below command in the Windows command line.

echo off | clip

After the above command has been entered, all contents within the Windows clipboard will be removed.



Open command window here

Open command window here

Open the Windows command line directory of any folder in Windows by holding down the Shift key on the keyboard, right-clicking on a folder, and choosing the Open command window here option from the menu that appears. Using this tip you can quickly open any folder in the Windows command line without having to use the Windows command line commands to navigate to that directory. In the picture to the right, is an example of what this menu looks like when done properly. Keep in mind, if you do not hold down the Shift key this option will not be visible





Use tab to auto complete commands in the command line

When at the MS-DOS, Windows command line, or a Linux or Unix shell typing in long file names or directories can become a burden. Use the tab key to auto complete the names of directories and files while in the command line. Below, are a few examples of how this can be done.
MS-DOS and Windows command line users
While at the prompt, typing in one or more letters a file or directory name contains will auto complete the name in alphabetical order. For example, when at the C:\> prompt type the below command.

cd p

After the above command has been typed, instead of pressing the enter press the tab key. When you press the tab key the first directory that begins with p will be automatically typed into the command. Continuing to press the tab key will cycle through all available directories including the "Program Files" directory. This shortcut can be used any time you need to type a file name or directory in a command.
Tip: If you type one or more beginning letters for a file name or directory that does not exist in the current directory, the tab key will not auto complete.
Most Linux and Unix users
Depending on your variant of Linux or Unix and if you're remotely connecting to a Linux box can change how the tab key is used for auto complete. However, below is a general run down on how this is commonly used in Linux. At the prompt in your home directory type the below command.

cd p

Assuming your home directory has "public_ftp", "public_html", or another file or directory that begins with 'p' you will be shown all available files and directories. If you continue to type the next letter available, for example, "cd pu" the command will complete the remaining of the file name or directory up to the point there is no conflict. If you had both directories mentioned earlier in the current directory, it would auto complete up to "public_" because there are two directories beginning with "public_". Pressing the tab key again will show you the remaining available files beginning with "public_". If you wanted to type "public_html", add a 'h' and then press tab to complete the directory name.



View command history and quickly repeat DOS commands

While at the MS-DOS prompt or in the Windows command line you can quickly repeat any previously entered command and view a history of commands by using the arrow keys. For example, if you previously used the dir command to list the files in the current directory press the up arrow key to repeat that command. Continuing to press the up arrow will scroll though a listing of commands that have been previously entered.
This is a fantastic tip for users who are entering long commands, file names, or directory names. If you happen to misType a command, pressing the up arrow and then using the left arrow to move to and correct the error can save you a lot of time.

Tip: This option is available in MS-DOS and the Windows command line through the use of the doskey command. See our doskey command page if you need additional help or would like to view all the available options for this command.

Copy command line output to clipboard

Microsoft Windows Vista and Windows 7 users can copy the output of command line commands such as dir to the clipboard by using the clip command. For example, if you wanted to copy the dir output to the clipboard you would type the below command.

dir |clip

Users who're not using these versions of Windows or other operating systems may not have access to this command but can send the output of commands to a file.


DOS and Windows command line Top 10 commands


Below is a listing of the top 10 MS-DOS commands most commonly used and that you will most likely be using during a normal DOS session.
  1. cd
  2. dir
  3. copy
  4. del
  5. edit
  6. move
  7. ren (rename)
  8. deltree
  9. cls
  10. format

MS-DOS secret or unknown commands

Below is a listing of MS-DOS commands that are not listed in any available help manual or in the commands syntax or are commonly unknown commands. Many of these commands that are known can be very useful when using MS-DOS, while some of the other commands are unknown or appear to do nothing.

Caution: Use these commands cautiously, some of the commands can erase data and some without warning.

ATTRIB , The command is short for ATTRIB -a -h -r - s *.* (removes all attributes of a file).
BACKUP /HP Unknown
DIR , This lists all files including hidden files, does not work in Windows 95, 98, NT, and 2000.
DIR ... Lists all directories that do not have extensions. In Windows 95 and Windows 98 will list the contents of the directories previous to the directory currently in.
DOSKEY /APPEDIT Utilize doskey functions in MS-DOS command utilities such as edlin and debug.
DOSKEY /COMMAND Unknown
DOSKEY /PERMANENT Unknown
DOSKEY /SCRSIZE Unknown
DOSKEY /XHISTORY Unknown
FDISK /MBR Recreates the Master Boot Record See CH000175 for additional information.
FDISK /PRI See FDISK Page for additional information.
FDISK /EXT See FDISK Page for additional information.
FDISK /LOG See FDISK Page for additional information.
FDISK /Q Prevents fdisk from booting the system automatically after exiting fdisk.
FDISK /STATUS Shows you the current status of your hard drives.
FORMAT /AUTOTEST Formats the hard drive without any prompting.
FORMAT /BACKUP Like /AUTOTEST but it will ask you for a volume label.
FORMAT /Z:n Command used with FDISK supporting FAT32, used to specify the cluster size in bytes where n is multiplied by 512.
MEM /A or /ALL Adds a line into the MEM command tells the available space in HMA.
RESTORE /Y Unknown
RESTORE /Z Unknown
SET DIRCMD=0 Will make all directories hidden however still accessible, to get them back SET DIRCMD=
SHARE /NC Unknown
TRUENAME When placed before a file, will display the whole directory that it exists.
VER /R Tells you the Revision and if DOS is in HMA.