12 Best Commands to Use in Windows Command Prompt (CMD)

Who I am
Carlos Laforet Coll
@carloslaforetcoll
Author and references

The Windows Command Prompt (CMD) is a program that interprets command lines. These commands allow you to automate tasks, troubleshoot and perform administrative functions on the system.

To access the application, just type cmd in the Windows search box. When it opens, write or paste the command next to the last line displayed and press the key Enter.

Despite being aimed at programmers and information technology professionals, the tool can be used by common users. To help, we've listed the 12 most useful commands below with an explanation of each of the features. Check out!



1. Find the right program to open a file

  • Command: Association

Files in Windows are saved in certain formats, which are usually assigned to specific programs. For example, a .doc file will by default open in Word, just as a .txt file can be read in Notepad.

The command Association displays a list in which it assigns extensions to associated programs by default.

2. Hide folder

  • Command: attrib +s +h “folder address”

The above command allows you to hide a folder that you don't want anyone to see. In this case, you must replace the term folder address with the address displayed in the bar, indicated in the image below.

If it does not appear in this address format, double click on the bar. In our example, the command was attrib +s +h "C:UserstaysaOneDriveDesktop". If the command is executed correctly, no message will be generated in the Promtp (which happens in case of errors).

To display the folder again, you must enter the command attrib -s -h "folder address”. So in our case it would be, attrib -s -h "C:UserstaysaOneDriveDesktop".



3. Delete files from a drive for good

  • Command: Cipher

When you delete a document or file from the computer, even if you delete it from the recycle bin, it will remain on the HD. Although the system prevents access and informs that the space has been freed, the item will only be deleted once in a while when it is replaced by new data. Which can take a while to happen.

The command Cipher clears deleted items from folders by writing random data to them. This prevents them from being recovered even when using a specialized app.

If you want to apply the command to a specific directory, just complement it with / in: followed by the folder name (no space). In the case of Drive C, for example, it would be cipher /w:c.

4. Search for bugs (and fix them)

  • Command: CHKDSK / f

The command CHKDSK / f checks a particular directory for errors and corrects them automatically when possible. The action checks for file fragmentation, disk problems and partition defects. To check disk C, for example, we will use the command: CHKDSK /f C.

In order for the scan to be performed, the file must not be in use. In such cases, it is possible to schedule the scan for when the PC restarts. If you get the message shown in the image above, just type S and press the key Enter to confirm.


If, by any chance, you receive the message that you do not have the privileges to perform the operation, you should open the Command Prompt as an administrator. To do this, search for cmd in the search bar and right-click on the result. In the menu that appears, go to Execute as administrator.


5. List all drivers installed on your machine

  • Command: driverquery

When using command driverquery, the Command Prompt will list all the drivers installed on your PC. Drivers are programs that allow specific hardware to communicate with the operating system and must always be kept up to date.

6. Discover and Update IP

  • Command: ipconfig

The command ipconfig displays the IP address, among other network data. An unfolding of the command also allows to change the IP address. For this, you must enter the ipconfig/release and press Enter, to release the current one, and then enter ipconfig/renew.

It is also possible to clear the DNS cache using the command ipconfig / flushdns. These combined features can often resolve issues of slowness or internet connection difficulties.

7. Discover an IP associated with a domain

  • Command: nslookup

The command nslookup lets you discover the IP associated with a website address. If you enter nslookup www.nasa.gov, you will see the IP address assigned to the NASA website server, for example. The opposite is also possible. By typing in an IP address, you can find out which site it refers to.


8. Test Ping

  • Command: ping

Ping, also known as bidirectional latency, is the reaction time of the internet. Corresponds to the measure of time, in milliseconds, for a data packet to leave the device, reach the destination and return to the source device.


The command ping, followed by a URL or IP address, tells you how long it takes for the data packet to leave your PC to get to the desired website and back. Remember that the smaller this range, the better. Application example: ping

9. Manage PC power

  • Command: Powercfg

The command Powercfg, associated with another instruction, can offer a number of options related to power management. In this case, you also need to run the Command Prompt as an administrator.

  • Powercfg /energy: Scans for 60 seconds for energy efficiency and battery consumption issues. The result is saved on the computer in a .html file, indicated at the end of the verification.
  • Powercfg /batteryreport: generates a report on battery usage, with information about the time and duration of charge and discharge cycles and average battery life. The result is also saved as an .html file.
  • Powercfg / lastwake: Indicates what woke the system the last time it was put into hibernation. It can be useful in cases where the PC wakes up on its own, wasting unnecessary energy.
  • powercfg hibernate on/ powercfg hibernate off: Enables and disables the hibernation option on notebooks. “Hibernate uses less power than Sleep, and when you restart your computer, it's back to where it was (but not as quickly as Sleep),” explains Microsoft.

10. Shut down or restart the PC

  • Command: Shutdown

The command Shutdown Allows you to shut down your computer via Command Prompt. Just like the previous one, combined with some guidelines, you can shut down and even restart the system in different ways. It can also be used to schedule a time for the PC to turn itself off.

  • Shutdown /s: Shut down the computer.
  • Shutdown /r: restarts the computer.
  • Shutdown /l: Logs off the current user.
  • Shutdown /h: Puts the PC into sleep state.
  • Shutdown /r /o: restarts the computer in Advanced Boot Options, where it finds system recovery features.

11. Check your computer's configuration

  • Command: systeminfo

How to see PC settings and get full specs

Want to know OS version information? What network card and processor are on your machine? Or how much memory do you still have available? The command systeminfo gathers this and many other information about your computer in one place.

12. Scan for corrupted files

  • Command: sfc / scannow

The command sfc / scannow scans to automatically discover and fix corrupt or error files. These problems can be caused by a virus or a software bug. To do this, the system replaces the problematic version of the files with a cached one.

On average, the process takes 15-30 minutes to complete. To use the command, you need to access the Command Prompt as an administrator.

Tips for using the Command Prompt

The Command Prompt interface, as well as the language used may not be the most friendly to less technical users. Some tips, however, can help in the use and familiarization process with the app. We list a few below.

Open Command Prompt in a specific folder

The trick makes it easier, since the commands executed will be aimed at the folder in which the Prompt was opened. Open the desired folder and double-click the address bar. Erase the path, type cmd and press the key Enter. Immediately, the Prompt will open with commands specific to that folder.

Stop a running command

Executed a command and regretted it? If you're quick, maybe you can stop him. Just press the keys Ctrl + C at the same time.

View command history

Used so many commands that you don't even remember what you did anymore? It is possible to check the history of actions in a simple way. Just press key F7 keyboard (in some cases, you need to press the fn key to activate F7).

The separate window allows you not only to move between commands but also to execute them by pressing Enter when it is selected.

Discover the function of a command

If you are in doubt about the function of a certain command, just enter /? after him. In addition to the explanation, examples of applications of the command are shown when combined with other terms.

recommends:

  • Best DNS servers to use in our country
  • The best Android emulators for PC right now
add a comment of 12 Best Commands to Use in Windows Command Prompt (CMD)
Comment sent successfully! We will review it in the next few hours.