The command prompt is still a powerful Windows tool. Here are the most useful CMD commands that every Windows user needs to know.
Command prompts are slowly disappearing from the Windows interface and for good reason: The CMD command is an ancient and largely unnecessary tool from the era of text-based input. But many commands remain useful, and Windows 8 and 10 even add new features.
Here we present the essential commands that every Windows user should know.
Command Prompt Windows Command
Most files in Windows are associated with a specific program that is assigned to open the file by default. Sometimes, remembering these associations can be confusing. You can remind yourself by entering the command assoc to display a complete list of filename extensions and program associations.
You can also expand the command to change file associations. For example, assoc .txt= will change the file association for a text file to whatever program you enter after the equals sign. Order Assoc itself will reveal the name of the extension and the name of the program, which will help you to use this command properly.
In Windows 10, you can see a more user-friendly interface that also lets you change file type associations on the spot. Go to Settings Settings (Windows + I) > Apps > Default apps > Select default apps by file type.
Deleting files on a mechanical hard drive doesn’t actually delete them at all. Instead, it marks files as no longer accessible and the space they use as free. Files remain recoverable until the system overwrites them with new data, which can take a long time.
The command cipher, however, deletes the directory by writing random data to it. To wipe your C drive, for example, you would use the command cipher /w:d which will clear the free space on the drive. The command does not overwrite data that is not deleted, so you will not delete the files you need by running this command.
Drivers remain one of the most important software installed on a PC. Improperly configured or missing drivers can cause all sorts of problems, so it’s a good idea to have access to a list of what’s on your PC. That’s what orders do driverquery. You can expand it to driverquery -v for more information, including the directory where the driver is installed.
You can use this command to identify text differences between two files. This is especially useful for writers and programmers trying to find minor changes between two versions of a file. Just type fc and then the directory paths and filenames of the two files you want to compare.
You can also expand the command in several ways. Type /b only compare binary output, /c ignores the case of text in comparison, and /l only compares ASCII text.
So, for example, you could use the following:
fc /l "C:Program Files (x86)example1.doc" "C:Program Files (x86)example2.doc"
The above command compares ASCII text in a two word document.
This command conveys the IP address that your computer is currently using. However, if you are behind a router (like most computers these days), you will instead receive the local network address of that router.
Entering command netstat -an will give you a list of currently open ports and associated IP addresses. This command will also tell you the status of the port; listening, established, or closed.
This is a good command when you are trying to troubleshoot a device connected to your PC or when you are afraid of a Trojan infecting your system and you are trying to find a malicious connection.
Sometimes, you need to know whether the packet is being sent to a particular network device or not. That’s where ping comes in handy.
Type ping followed by the IP address or web domain will send a series of test packets to the specified address. If they arrive and are returned, you know that the device is capable of communicating with your PC; if it fails, you know that something is blocking communication between your device and your computer. This can help you decide if the root of the problem is improper configuration or network hardware failure.
This is a more advanced version of ping which is useful if there are multiple routers between your PC and the device you are testing. Like ping, you use this command by typing pathping followed by the IP address, but unlike a ping, the path also conveys some information about the route the test packet took.
Order tracert similar to path. Again, type tracert followed by the IP address or domain you want to track. You will receive information about each step in the route between your PC and the target. Unlike paths, however, tracert also tracks how much time (in milliseconds) it takes each jump between servers or devices.
Powercfg is a very powerful command for managing and tracking how your computer uses energy. You can use the command powercfg hibernate on and powercfg hibernate off to manage hibernation, and you can also use the command powercfg /a to view the power-saving status currently available on your PC.
Another useful command is powercfg /devicequery s1_supported, which displays a list of devices on your computer that support connected standby. When activated, you can use this device to wake your computer from standby, even remotely. You can activate it by selecting the device in Device Manager, opens its properties, opens a tab Power Management, then check the box Allow this device to wake the computer.
Powercfg /lastwake will show you what device last woke your PC from sleep. You can use this command to troubleshoot your PC if it seems to wake up from sleep randomly.
You can use the command powercfg /energy to generate detailed power consumption reports for your PC. The report is saved to the indicated directory after the command is completed. This report will notify you of system errors that can increase power consumption, such as devices blocking certain sleep modes, or not being configured properly to respond to your power management settings.
Windows 8 added powercfg /batteryreport, which provides a detailed analysis of battery usage, if any. Typically issued to your Windows user directory, the report provides details on charge and discharge cycle times and lengths, average battery life, and estimated battery capacity.
This is, of course, overkill with the already easily accessible shutdown button, but what isn’t superfluous is the command shutdown /r /o, which restarts your PC and launches the Advanced Start Options menu, where you can access Safe Mode and Windows recovery utilities. This is useful if you want to restart your computer for troubleshooting purposes.
This command will give you a detailed configuration overview of your computer. This list includes your operating system and hardware. For example, you can search for genuine Windows installation date, last boot time, BIOS version, total and available memory, installed hotfixes, network card configuration, and more.
use systeminfo /s followed by the hostname of the computer on your local network, to remotely retrieve information for that system. This may require additional syntax elements for the domain, username, and password, like this:
systeminfo /s [host_name] /u [domain][user_name] /p [user_password]
System File Checker
You need to run a command prompt with administrator rights and enter the command sfc /scannow. If SFC finds a corrupted or missing file, it will automatically replace it using a cached copy stored by Windows for this purpose only. The command took half an hour to run on the old notebook.
You can use the command tasklist to provide a current list of all the tasks running on your PC. While it’s a bit redundant with Task Manager, the command sometimes finds tasks hidden from view in that utility.
There are also various kinds of modifiers. Tasklist -svc display the services associated with each task, use tasklist -v to get more details about each task, and tasklist -m will find the DLL files associated with the active task. These commands are useful for advanced troubleshooting.
Our reader Eric notes that you can “get the executable name associated with the specific process ID you’re interested in.” The command for that operation is tasklist | find [process id].
Tasks that appear in the command tasklist will have an executable ID and a process (four or five digit number) associated with it. You can force stop the program using taskkill -im followed by the name of the executable, or taskkill -pid followed by the process ID. Again, this is a bit redundant with Task Manager, but you can use it to kill unresponsive or hidden programs.
Windows automatically marks your drive for a diagnostic chkdsk scan when symptoms indicate that the local drive has bad sectors, missing clusters, or other logical or physical errors.
If you suspect your hard drive is damaged, you can start the scan manually. The most basic command is chkdsk c:, which will immediately scan the C: drive, without restarting the computer. If you add parameters such as /f, /r, /x, or /b, as in chkdsk /f /r /x /bc:, chkdsk will also repair errors, recover data, unmount the drive, or clear the list of bad sectors, respectively. This action requires a reboot, as it can only be run with Windows turned off.
If you see chkdsk runs on startup, let it do its job. However, if it crashes, check out our chkdsk troubleshooting article.
Schtasks is your command prompt access to Task Scheduler, one of the many underrated Windows administrative tools. While you can use the GUI to manage scheduled tasks, the command prompt lets you copy & paste complex commands to set up several similar tasks without having to click on various options. In the end, it’s much easier to use, once you put the key parameters in memory.
For example, you can schedule your computer to reboot at 11 p.m. every Friday:
schtasks /create /sc weekly /d FRI /tn "auto reboot computer weekly" /st 23:00 /tr "shutdown -r -f -t 10"
To complete your weekly reboot, you can schedule a task to launch a specific program at startup:
schtasks /create /sc onstart /tn "launch Chrome on startup" /tr "C:Program Files (x86)GoogleChromeApplicationChrome.exe"
To duplicate the above command for a different program, simply copy, paste, and modify as needed.
Almost all Windows 8/8.1 computers ship from the factory with a recovery image, but the image may include bloatware that would rather not be reinstalled. After you uninstall the software, you can create a new image using the command recimg. Entering this command provides a very detailed explanation of how to use it.
You must have administrator rights to use the command recimg, and you can only access the custom recovery image you created via the feature refresh Windows 8.