New to using the command prompt? Check out the Windows Command Prompt Beginner’s Guide
In this guide, we’ll show you some commands you can use on the Windows Command prompt. These commands can save you time if you learn how to use them and rely on them to help you manage your PC.
Not sure how to get to the command prompt? How to open the command prompt in Windows.
Want to customize the command prompt? Customize the appearance of the command prompt.
Want to get more comfortable using the command prompt? Become a Command Prompt Super User
I’ve divided the commands into the following two sections:
- Commands to find system information.
- Commands to maintain your PC.
At any time, you can enter the command and succeed it with a /? to find out the list of parameters you can use with the command i.e. driverquery /?
You can also output the results of a command to a text file, csv etc. by adding >>out.txt or >>output.csv etc to the end of a command. The file will be saved in the current working directory (listed next to the command line.)
Commands to Find System Information
The systeminfo command will give you detailed system information. You can select specific information i.e. Virtual memory with the following syntax:
systeminfo |find "Virtual Memory"
More information on systeminfo.
Want to see a list of running tasks? The tasklist command will show you all tasks running on your PC.
More information on tasklist.
The ipconfig /all command will show you information about TCP/IP information on your PC. Here I show you how to use ipconfig to fix your internet connection.
More information on ipconfig.
Angel explores netstat, ipconfig, and other basic network commands in this post: Basic Network Commands and their Usage [Introduction].
More information on netstat.
Curious about what drivers are currently installed on your PC? Use driverquery to see the list. The output is a little vague so you may need to use the /v parameter to get more detailed information.
More information on driverquery.
Want to know which files are open and by which programs? Want to know which network shares are mapped and by which PC? Run the openfiles command to view this information. The output will likely be pretty large, so you can output it to a CSV file with the following syntax:
openfiles /query /fo csv >>out.csv
More information on openfiles.
Commands to Maintain Your PC
You can also maintain your PC with commands. Here are just a few examples:
taskkill is used to kill tasks that are hung or that you just want to kill. There some switches that allow forceful task killing (/f) etc.
taskkill /im chrome.exe /f
The above command forcefully kills Google Chrome.
More information on taskkill.
The rexec command authenticates you on a remote PC and lets you run commands. Want to defrag a PC remotely? Use the following syntax:
rexec GVD defrag D: /F
GVD is the name of the remote PC in this example.
More information on rexec.
subst maps a folder to a drive. If, for example you want to make the Windows folder the W drive, run the following command:
subst W: C:\windows
More information on subst.
Want to shutdown your PC or a remote PC? Want to leave a nice message and specify how long the computer will wait before shutting down? Use the following syntax:
shutdown /t 20 /m \\GVD /c "20 seconds till shutdown"
This will shutdown PC “GVD” 20 seconds from the time the command is run.
More information on shutdown.
Create a Batch File of Any Command
If you want to automate a command (i.e. run it on a schedule, on startup, shutdown etc.) you should create a batch file. Use the following syntax in your .bat file.
%windir%\System32\cmd.exe /c "ipconfig /all"
If you want to see the output of the command, add PAUSE to the end of the batch file.
What commands did I miss? Do you have any other commands you use on a regular basis?