The command prompt is still a powerful Windows tool. Here are the most useful CMD commands every Windows user needs to know.
The command prompt is slowly disappearing from the Windows interface and for good reasons: CMD commands are an antiquated and mostly unnecessary tool from an era of text-based input. But many commands remain useful, and Windows 8 and 10 even added new features.
Here we present the essential commands every Windows user must know.
Windows Command Prompt Commands
1. Assoc
Most files in Windows are associated with a specific program that is assigned to open the file by default. At times, remembering these associations can become confusing. You can remind yourself by entering the command assoc to display a full list of filename extensions and program associations.
2. Cipher
The cipher command, however, wipes a directory by writing random data to it. To wipe your C drive, for example, you’d use the cipher /w:d command, which will wipe free space on the drive. The command does not overwrite undeleted data, so you will not wipe out the files you need by running this command.
3. Driverquery
Drivers remain among the most important software installed on a PC. Improperly configured, missing, or old drivers in Windows can cause all sorts of trouble, so it’s good to have access to a list of what’s on your PC.
4. File Compare
You can use this command to identify differences in text between two files. It’s particularly useful for writers and programmers trying to find small changes between two versions of a file. Simply type fc and then the directory path and file name of the two files you want to compare.
5. Ipconfig
This command relays the IP address that your computer is currently using. However, if you’re behind a router (like most computers today), you’ll instead receive the local network address of the router.
Still, ipconfig is useful because of its extensions. ipconfig /release followed by ipconfig /renew can force your Windows PC into asking for a new IP address, which is useful if your computer claims one isn’t available. You can also use ipconfig /flushdns to refresh your DNS address.
6. Netstat
Entering the command netstat -an will provide you with a list of currently open ports and related IP addresses. This command will also tell you what state the port is in; listening, established, or closed.
7. Ping
Sometimes, you need to know whether or not packets are making it to a specific networked device. That’s where ping comes in handy.
Typing ping followed by an IP address or web domain will send a series of test packets to the specified address. If they arrive and are returned, you know the device is capable of communicating with your PC; if it fails, you know that there’s something blocking communication between the device and your computer. This can help you decide if the root of the issue is an improper configuration or a failure of network hardware.
8. PathPing
9. Tracert
10. Powercfg
Another useful command is powercfg /devicequery s1_supported, which displays a list of devices on your computer that support connected standby. When enabled, you can use these devices to bring your computer out of standby, even remotely.
You can enable this by selecting the device in Device Manager, opening its properties, going to the Power Management tab, and then checking the Allow this device to wake the computer box.
Powercfg /lastwake will show you what device last woke your PC from a sleep state. You can use this command to troubleshoot your PC if it seems to wake from sleep at random.
You can use the powercfg /energy command to build a detailed power consumption report for your PC. The report saves to the directory indicated after the command finishes.
This report will let you know of any system faults that might increase power consumption, like devices blocking certain sleep modes, or poorly configured to respond to your power management settings.
Windows 8 added powercfg /batteryreport, which provides a detailed analysis of battery use, if applicable. Normally output to your Windows user directory, the report provides details about the time and length of charge and discharge cycles, lifetime average battery life, and estimated battery capacity.
11. Shutdown
This is, of course, redundant with the already easily accessed shutdown button, but what’s not redundant is the shutdown /r /o command, which restarts your PC and launches the Advanced Start Options menu, which is where you can access Safe Mode and Windows recovery utilities. This is useful if you want to restart your computer for troubleshooting purposes.
12. Systeminfo
Use systeminfo /s followed by the hostname of a computer on your local network, to remotely grab the information for that system. This may require additional syntax elements for the domain, user name, and password, like this:
systeminfo /s [host_name] /u [domain]\[user_name] /p [user_password]
13. System File Checker
You will need to run the command prompt with administrator privileges and enter the command sfc /scannow. If SFC finds any corrupt or missing files, it will automatically replace them using cached copies kept by Windows for this purpose alone. The command can require a half-hour to run on older notebooks.
14. Tasklist
There’s also a wide range of modifiers. Tasklist -svc shows services related to each task, use tasklist -v to obtain more detail on each task, and tasklist -m will locate DLL files associated with active tasks. These commands are useful for advanced troubleshooting.
Our reader Eric noted that you can “get the name of the executable associated with the particular process ID you’re interested in.” The command for that operation is tasklist | find [process id].
15. Taskkill
16. Chkdsk
If you suspect your hard drive is failing, you can manually initiate a scan. The most basic command is chkdsk c:, which will immediately scan the C: drive, without a need to restart the computer. If you add parameters like /f, /r, /x, or /b, such as in chkdsk /f /r /x /b c:, chkdsk will also fix errors, recover data, dismount the drive, or clear the list of bad sectors, respectively. These actions require a reboot, as they can only run with Windows powered down.
If you see chkdsk run at startup, let it do its thing. If it gets stuck, however, refer to our chkdsk troubleshooting article.
17. schtasks
For example, you could schedule your computer to reboot at 11pm every Friday:
schtasks /create /sc weekly /d FRI /tn "auto reboot computer weekly" /st 23:00 /tr "shutdown -r -f -t 10"
To complement your weekly reboot, you could schedule tasks to launch specific programs on startup:
schtasks /create /sc onstart /tn "launch Chrome on startup" /tr "C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe"
To duplicate the above command for different programs, just copy, paste, and modify it as needed.
18. Format
The command below will quick-format the D drive with the exFAT file system, with an allocation unit size of 2048 bytes, and rename the volume to “label” (without the quotes).
format D: /Q /FS:exFAT /A:2048 /V:label
You can also use this command to dismount a volume (/X) or, if it’s formatted with NTFS, make file compression the default setting (/R). If you’re stuck, use format /? to summon help.
19. prompt
Would you like to customize your command prompt to include instructions or certain information? With the prompt command, you can!
Try this one:
prompt Your wish is my command:
You can add the current time, date, drive and path, Windows version number, and so much more.
prompt $t on $d at $p using $v:
Type “prompt” to reset your command prompt to default settings or just restart the command prompt. Unfortunately, these settings aren’t permanent.
20. cls
Cluttered up your command prompt window trying out all the commands above? There’s one last command you need to know to clean it all up again.
cls
That’s all. Bet Marie Kondo didn’t know that one.
Windows 8 Only: Recovery Image
Virtually all Windows 8/8.1 computers ship from the factory with a recovery image, but the image may include bloatware you’d rather not have re-installed. Once you’ve uninstalled the software you can create a new image using the recimg command. Entering this command presents a very detailed explanation of how to use it.
You must have administrator privileges to use the recimg command, and you can only access the custom recovery image you create via the Windows 8 refresh feature.
In Windows 10, system recovery has changed. Windows 10 systems don’t come with a recovery partition, which makes it more important than ever to back up your data.