15 Windows Command Prompt (CMD) Commands You Need to Know

The Command Prompt is slowly disappearing from the Windows interface, and for good reason: CMD commands are an outdated and mostly unnecessary tool from an era of text-based input. But many commands remain useful, and Windows 8 and 10 have even added new features.

Here we present the essential commands that every Windows user needs to know.

Not sure how to access the Windows Command Prompt , have you forgotten basic Windows commands, or would like to know how to display a list of options for each command (i.e. prompt codes)? Refer to our beginner’s guide to the Windows command line for instructions.

Windows command prompt commands

1. Assoc

Most files in Windows are associated with a specific program assigned to open the file by default. Sometimes remembering these associations can be confusing. You can remind yourself of this by entering the assoc command to see a complete list of file name extensions and program associations.

You can also extend the command to change file associations. For example, assoc .txt = will change the file association for text files to any program entered after the equal sign. The Assoc command itself will reveal both extension names and program names, which will help you use this command correctly.

In Windows 10, you can see a more intuitive interface that also allows you to change file type associations on the spot. Go to Settings (Windows + I)> Apps> Default apps> Choose default app by file type .

2. Cipher

Deleting files on a mechanical hard drive does not delete them at all. Instead, it marks the files as no longer accessible and the space they occupied as free. The files remain recoverable until the system overwrites them with new data, which can take some time.

The cipher command, however, deletes a directory by writing random data to it. To wipe your C drive, for example, you should use the cipher / w: d command , which will wipe the free space on the drive. The command does not overwrite any data not deleted, so you will not delete necessary files by running this command.

A number of other encryption commands can be used, however, they are generally redundant with BitLocker-enabled versions of Windows .

3. Driverquery

Drivers remain among the most important software installed on a PC. Incorrectly configured or missing drivers can cause all kinds of problems, so it’s good to have access to a list of what’s on your PC. This is exactly what the driverquery command does . You can extend it to driverquery -v to get more information, including the directory where the driver is installed.

4. Compare files

You can use this command to identify text differences between two files. It is especially useful for writers and programmers trying to find small changes between two versions of a file. Simply type fc, then the directory path and filename of the two files you want to compare.

You can also extend the command in several ways. Entering / b compares only the binary output, / c ignores the case of the text in the comparison, and / l compares only the 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 two word documents.

5. Ipconfig

This command forwards the IP address currently used by the computer. However, if you are behind a router (like most computers today), you will get the router’s local network address instead.

However, ipconfig is useful thanks to its extensions. ipconfig / release followed by ipconfig / renew can force your Windows PC to ask for a new IP address, which is useful if your computer claims one is not available. You can also use ipconfig / flushdns to update your DNS address. These commands are great if the Windows Network Troubleshooter crashes, which happens occasionally.

6. Netstat

Entering the netstat -an command will give you a list of currently open ports and their IP addresses. This command will also tell you what state the door is in; listening, established or closed.

This is a great command for when you are trying to troubleshoot devices connected to your PC or when you are concerned that a Trojan has infected your system and you are trying to detect a malicious connection.

7. Ping

Sometimes, you need to know whether or not packets are arriving at a specific network device. This is where ping comes in handy.

Entering 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 that the device is able to communicate with your PC; if it fails, you know that there is something blocking the communication between the device and your computer. This can help you decide if the root of the problem is an improper configuration or network hardware failure.

8. PathPing

This is a more advanced version of ping which is useful if there are multiple routers between the PC and the device you are testing. Like ping, you use this command by typing pathping followed by the IP address, but unlike ping, pathping also transmits some information about the path taken by test packets.

9. Tracert

The tracert command is similar to pathping. Again, type tracert followed by the IP address or domain you wish to track. You will receive information on every step of the way between your PC and the goal. Unlike pathping, however, tracert also tracks the time (in milliseconds) taken by each pass between servers or devices.

10. Powercfg

Powercfg is a very powerful command for managing and monitoring how the computer uses energy. You can use the powercfg hibernate on and powercfg hibernate off command to manage hibernation, and you can also use the powercfg / a command to view the power saving states currently available on your PC.

Another useful command is powercfg / devicequery s1_supported , which displays a list of devices on the computer that support connected standby. When they are enabled, you can use these devices to take your computer out of standby, even remotely. You can enable it by selecting the device in Device Manager , opening its properties, going to the board energy saving , then selecting the box Allow this device to wake the computer .

Powercfg / lastwake it will show you which device has reactivated the PC to last from a state of suspension . You can use this command to troubleshoot your PC if it appears to wake up from sleep randomly.

You can use the powercfg / energy command to create a detailed power consumption report for your PC. The report is saved in the directory indicated at the end of the command. This report will notify you of any system errors that may increase power consumption, such as devices blocking certain sleep modes or misconfigured to respond to power management settings.

Windows 8 has added powercfg / batteryreport , which provides a detailed analysis of battery usage, if applicable. Normally posted to the Windows user directory, the report provides details on the time and duration of the charge and discharge cycles, average battery life, and estimated battery capacity.

11. Stop

Windows 8 introduced the shutdown command which, you guessed it, turns off the computer .

This is, of course, redundant with the shutdown button already easily accessible, but what isn’t redundant is the shutdown / r / o command , which restarts the PC and launches the Advanced Boot Options menu, from which you can enter the mode safe and Windows recovery utility. This is useful if you want to restart your computer for troubleshooting.

12. Systeminfo

This command will give you a detailed overview of your computer’s configuration. The list covers the operating system and hardware. For example, you can search for the original Windows installation date, last boot time, BIOS version, total and available memory, installed hotfixes, network card configurations, and more.

Use system info followed by the host name of a computer on your local network to remotely acquire 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]

  1. System File Checker

System File Checker is an automatic scan and repair tool that focuses on Windows system files.

You will need to run Command Prompt with administrator privileges and enter the sfc / scannow command . If SFC finds corrupt or missing files, it will automatically replace them using cached copies kept by Windows for this purpose only. The command can take half an hour to run on older notebooks.

14. List of activities

You can use the tasklist command to provide a current list of all the tasks running on the PC. While somewhat redundant with Task Manager, the command can sometimes find hidden tasks from view in that utility.

There is also a wide range of modifiers. Tasklist -svc shows the services related to each task, use tasklist -v to get more details about each task and tasklist -m will locate the DLL files associated with the active tasks. These commands are useful for advanced troubleshooting.

Our reader Eric noted that you can “get the executable name associated with the particular process ID you are interested in”. The command for this is tasklist | find [process ID].

15. Taskkill

The tasks displayed in the tasklist command will have an executable and a process ID (a four or five digit number) associated with them. You can force a program to stop by using taskkill -im followed by the executable name or taskkill -pid followed by the process ID . Again, this is a bit redundant with Task Manager, but you can use it to kill otherwise unresponsive or hidden programs.

16. Chkdsk

Windows automatically flags the drive for a diagnostic chkdsk scan when symptoms indicate that a local drive has bad sectors, lost clusters, or other logical or physical errors.

If you suspect your hard drive is not working, you can manually initiate a scan. The simplest command is chkdsk c :, which will immediately scan the C: drive, without having to restart your computer. If you add parameters like / f, / r, / x or / b, like in chkdsk / f / r / x / bc :, chkdsk will also fix errors, recover data, unmount the drive or clear bad sector list , respectively. These actions require a restart, as they can only be performed with Windows turned off.

If you see chkdsk running on startup, let it do its thing. If it crashes, however, refer to our chkdsk troubleshooting article .

17. schtasks

Schtasks is the command prompt’s access to Task Scheduler, one of the many underrated Windows administration tools. Although you can use the GUI to manage scheduled tasks, the command prompt allows you to copy and paste complex commands to set up multiple similar tasks without having to click on various options. Ultimately, it’s much easier to use once you’ve got the key parameters memorized.

For example, you can schedule your computer to restart at 11:00 PM every Friday:

schtasks /create /sc weekly /d FRI /tn “auto reboot computer weekly” /st 23:00 /tr “shutdown -r -f -t 10”

To complete the weekly restart, you can schedule tasks to start specific programs at startup:

schtasks /create /sc onstart /tn “launch Chrome on startup” /tr “C:Program Files (x86)GoogleChromeApplicationChrome.exe”

To duplicate the previous command for several programs, just copy, paste and modify it as needed.

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 that you would rather not reinstall. After uninstalling 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 need to have administrator privileges to use the recimg command, and you can only access the custom recovery image created through the Windows 8 update feature .

In Windows 10, system restore has changed. Windows 10 systems don’t come with a recovery partition, which makes backing up your data more important than ever.

Command and conquer your Windows PC

This article can only give you a taste of what is hidden in the Windows command line. When all variables are included, there are literally hundreds of commands. Download the Microsoft Command Line Reference Guide (in Edge or Internet Explorer) for advanced support and troubleshooting.

 

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment