Windows Command Prompt utilities

Here are just a few commands and the most used , with a small description:

Start > Run > cmd

and the Command Prompt window will apear

cmd.exe (Windows 2000 and XP), (98 and Me): These commands (you don’t need to enter the period and extension) open the window where you enter the other commands discussed here. Using either one with the /c switch, you can create a shortcut that opens a command window, executes a command, and then closes the window. This allows you to launch a command just by double-clicking its icon or choosing it from the Start menu. For example, to make an icon that refreshes your network connection, right-click the desktop or in any folder window and choose New, Shortcut. In the first box, type cmd /c ipconfig /renew , as well as the discussion of ‘ipconfig.exe‘ below). Click Next and follow the wizard’s instructions to create the shortcut. If you want the command window to stay open so that you can see the results of your command, simply replace the ‘/c’ with /k. You can use this shortcut technique with many of the commands listed here.

: This command lets you change one or more of a file’s attributes (such as ‘Hidden’, ‘System’, ‘Read-only’, or ‘Archive’). It’s usually easier to right-click the file in an Explorer or folder window, choose Properties, and check the desired boxes But when you need to change attributes for files in multiple subfolders, this command line (with the /s switch) can do it for you in one step.

compact.exe: If your drive is formatted with the NTFS file system (available only in Windows 2000 and XP), you have the option of compressing files and folders by right-clicking them, choosing Properties, clicking Advanced under the General tab, and selecting the appropriate check box. But what if some of the files in a folder are already compressed (such as JPEG photos), while others could benefit from compressing? Use this command with the /s switch and wild-card characters to compress only specific files in the selected directory (and in all its subdirectories). For example, compact /c /s:c:\doc *.doc will compress all of the Word documents in your Doc folder and subfolders. To uncompress, change the ‘/c’ to /u.

ipconfig.exe: This helpful network utility displays your current IP address, as well as its subnet and gateway addresses. Use the /all switch to see even more network information. The /renew switch (/renew_all in Windows 98 and Me) refreshes the connections. (See also ‘ping.exe’ below.)

openfiles.exe: If you need to figure out who on your network has a shared file open, type this command at the prompt and press <Enter>. You can also use it to close the open files in a shared folder or to disconnect the user currently viewing them. For details, type openfiles /disconnect /? at the command prompt.

ping.exe: When your network is experiencing technical difficulties, this simple troubleshooting utility will tell you whether two computers are talking to each other. Just type ping, a space, and the network name or IP address of the problem computer. If it reports a reply, you’ll know that the connection is okay. You can also use this command to confirm that your own Internet connection is working.

recover.exe: If you lose a file to a corrupt sector on an NTFS disk, this command restores as much of the lost data as possible. Type recover followed by a space and the full path and name of the file you want to resuscitate. No wild-card characters are allowed in the specified file path, and you can recover only one file at a time when using this command.

runas.exe: People who log in to a non-administrator Windows account (which Microsoft recommends for security reasons) may think that they have to log off and back on to perform administrator-only tasks. Not so! This command launches a program as if you were another user. Just type runas /user: followed by the name of the profile under whose auspices you want to run the application, then a space and the program’s name. (Use the /? switch to get details on the exact form to use with this command.) You will, of course, be prompted for that profile’s password before the program launches.

sort.exe: To sort the items in a text file alphabetically, type sort, a space, the name of the file, another space, the greater-than symbol (>), another space, and the path and name of the file in which the sorted entries will appear (for example, you might type sort messylist.txt > neatlist.txt). Add the /r switch at the end if you want the list to appear in reverse alphabetical order.

taskkill.exe: You could use Windows XP’s Task Manager to close any running application or process, but this utility not only closes one app, it also lets you stop multiple programs at once via wild cards and filters. For example, to shut down all applications that are not responding, type taskkill /fi “status eq not responding”. For more options, consult the help screen.


Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
Microsoft Corporation. All rights reserved. Terms of Use | Trademarks


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

To prove that you're not a bot, enter this code
Anti-Spam Image