![]() |
||||
|
Broadband - Exchange Terminal Services / Limiting the Number of Logins a User Can Make |
Command Prompt Basics
Many of the hints and tips on this and other sites make use of the DOS or Command Prompt. This is how computers used to work before the mouse became common. You have to type in your commands. Throughout this page you will see this referred to as a command prompt. DOS Prompt and Command Prompt are the same thing. You should have a Command Prompt open when reading this page so that you can try the commands. Unless stated, you will not damage your data by just moving around your folders. Opening a Command Prompt There are two conventional ways to start a Command prompt.
You can also use Microsoft power toys to open a command prompt from Windows Explorer. You can read more about the power toys further down this page, here. The screenshot below shows a Command Prompt on Windows XP.
Command Prompt Basics When you are working in Command Prompt, there are a couple of things that usually work: Many of the commands will have extra options available, known as switches. They are added to the command by entering a "/" then a letter, number or word. These can change how the tool works or handles the information. A common switch would be the help command, which will also give you information on the other switches available. <command> /? <command> > <filename>.txt xcopy /? >c:\xcopy.txt This writes the content of the help command to a file called xcopy.txt located in the root of the C:\ drive. CLS Frequently Used Command Prompt Entries There are two commands you will use most
DIR The "Dir" command is probably the most basic command. It gives you a listing of all the files and folders that are located in the folder that you are currently open in. Volume in drive C is System Advanced "dir" commands You can get a little more advanced with the dir command by putting extra commands after the intitial "dir". dir /s will show the contents of the current folder, and any subfolders that are below. This will produce a very long file listing. You might want to filter the results or send them to a text file (see above). dir /s something.doc This command will search through all subdirectories below for a file that matches that file name. Similarly, issuing the command dir /s *.doc will list all files that end in .doc (Word files). CD The CD command is very simple to use. All commands are relative to the directory that you are in. Therefore, using the example output of a "dir" that is shown above, if you want to change to the "Windows" directory, you would type CD Windows If you want to change to the "system" directory (which is a sub directory of "windows"), you would enter CD System However if you knew that you wanted to change to the system directory immediately, you could type this command instead: CD Windows\System However if you were already deep in another directory (for example c:\ documents and settings \username\ local settings) and then wanted to move directly to windows\system then you can do that by putting in an initial backwards slash: CD \Windows\System This tells the command to go to the root of the drive, then to the directory Windows and system. Moving Back Up You can also move back up the tree, instead of down. If you want to just return to the root of the drive (C:\) you would just type cd \ or cd\ If you wanted to just go back one level (to use the earlier example, you were in c:\windows\system and you wanted to be in c:\windows) you would just type: cd.. Alternatively, if you want to access a totally different directory, for example "Program Files" you could type cd program files or cd "program files" When typing directories to change to, if the directory name is unique, then you can use wild cards. For example cd program* Directory Entry Shortcut: : If you are on Windows 2000 or XP and you have a Windows Explorer screen open at the location that you want to run a Command Prompt command you could open the Command Prompt and typing a long series of directories or CD commands. Instead, just type CD and then a space, then drag and drop the directory you want to work in to the Command Prompt window. The full path to the directory will be entered, ready for you to press enter. More Commands File Renaming You can rename files in a command prompt. rename something.txt someone.txt would rename the file something.txt to someone.txt Directory Creation You can create directories from the command prompt: mkdir something would create a directory called "something". mkdir "my files" This ensures that the directory is created with the space. Without the space you will get a new directory called "my" and an error message. If you do a lot of work in the command prompt, then you might be interested in installing the "Command Prompt Here" (Windows 9x, NT and 2000) or "Command Here" (Windows XP) Power Toys. These add a new command the right click menu you get when you click on a directory allowing you to open a Command Prompt in that directory. You can download these Power Toys from Microsoft's web site. Keyboard Short Cuts There are a couple of shortcuts that you can use from the keyboard instead of typing full directory paths. Use a Wild Card If the directory you are wanting to change to is very long but uniquely named, then you can use a wild card instead of typing the entire thing. For example, instead of: cd "program files" you could enter cd prog* Enter the wildcard character once you have typed enough characters for Windows to only have one choice. Using "Tab" to Select Files or Folders - Windows XP/Server 2003 only Another neat trick if you are using a command prompt on Windows XP or Windows Server 2003 and is to use the "Tab" key to scroll through the files and folders in the current directory. Type the command you want to use as normal, for example "cd" then press tab to cycle through the files and folders until you reach the one you want. Then press enter. You may still have to enter the " as before, so would type " cd " " then press tab until you reached the folder you want to change to, enter the second " to finish off and press enter. Repeat a Command If you want to repeat a command that you have just run, or adjust something in the last command, press the "Up" cursor key to bring it back. You can then adjust it and press enter. Useful if you are trying to work out what switches and options you can use to achieve a certain result. Full Command Listing If you want a full list of the commands available to you, just type "help" and they will be listed. You can then type "help <command>" for the instructions. Screen Size and Buffer Size When you are working with a Command Prompt, it maybe helpful to increase the screen size or the buffer size. To change the screen size and buffer size, right click on the icon in the top left corner of the Command Prompt window and choose Properties. Then click on layout. After pressing OK you will be asked if you want to apply the changes to the shortcut or the current window only. If you are testing, select the current window only. Deleting Files Finally - remember that if you delete a file within a Command Prompt session it does not go in to the recycle bin. It will be deleted immediately. Further Reading You can purchase books which cover the Command Prompt in more depth from our Amazon Store. Sponsored Links | |||
| Last Page Update: 26/02/2007 |
Back to the Top Broadband - Exchange - Login Scripts - Network Admin - Outlook - Windows Mobile - Windows © Sembee Ltd. 1998 - 2009. All rights reserved. Reproduction of any content on this web site is prohibited without express written consent. Use of this web site is subject to our terms and conditions. All trademarks and registered trademarks are property of their respective owners. This site is not endorsed or recommended by any company or organisation mentioned on this site. This site is to provide guidance only and as such we cannot be held responsible for any consequences of following the advice given. |
|||