The Windows command prompt is a feature that’s been a core part of the Windows operating system for a long time. There are some CMD commands that are so useful and easy to use that even regular users see the Windows command prompt as a key part of the operating system.

There are always rumors that it will be phased out at some point, but that’s unlikely to happen any time soon.

The following are some of the best CMD commands you should know if you want to have more control over your Windows PC.

1. Delete folders with subfolders

rmdir PATH\TO\FOLDER-NAME

//OR
rm PATH\TO\FOLDER-NAME

The above example removes the folder with the name “FOLDER_NAME”.

Type the following command to delete folder and subfolders with contents  :

rmdir /s PATH\TO\FOLDER-NAME

//OR

rm -r PATH\TO\FOLDER-NAME

2. ASSOC: Fix File Associations

One of the most powerful tools in the CMD command library is the ASSOC command.

Your computer associates certain file extensions with certain programs. This is how your computer knows to open Adobe when you double click a PDF file, or Microsoft Word when you double click a DOC file.

You can view all the file associations your computer knows about by typing ASSOC in the command window. You’ll see the file extension and the program it’s associated with.

You can set the association by typing something like assoc .doc=Word.Document.8.

3. FC: File Compare

Sometimes when files are changed over time, it’s hard to remember what the differences were between versions. You may not know that a CMD command offers the ability to compare files and see all differences, but it’s true.

The FC command performs either an ascii or a binary file comparison and will list all of the differences that it finds.

Fc /a File1.txt File2.txt will compare two ascii files.

Fc /b Picture1.jpg Picture2.jpg will do a binary compare on two images.

4. IPCONFIG: IP Configuration

Network troubleshooting is never simple, but one command that makes it much easier is IPCONFIG.

Using this command in the CMD command prompt returns detailed information about your current network adapter connection including:

  • Current IP Address
  • Subnet Mask
  • Default Gateway IP
  • Current domain

This information can help you troubleshoot router issues and other connection issues you could be having with your network adapter.

This image has an empty alt attribute; its file name is image-9.png

5. NETSTAT: Network Statistics

Concerned that you could have malware running on your computer that’s connecting to internet locations without you knowing about it?

If you run a NETSTAT command in the command prompt, you can get a list of all active TCP connections from your computer.

6. PING: Send Test Packets

An IT Analyst’s best friend is the PING command.  Running this command sends test packets over the network to the target system.

You can use the PING command to test whether your computer can access another computer, a server, or even a website. It can help with revealing network disconnections. It also provides transit time for the packets in milliseconds, so it also reveals a bad network connection as well.

7. TRACERT: Trace Route

TRACERT is a fascinating Windows Command to use. If you’re ever curious to see the path your internet traffic takes to get from your browser to a remote system like Google servers, you can use TRACERT to see it.

The command stands for “Trace Route”, which sends packets out to a remote destination (server or website), and provides you with all of the following information:

  • Number of hops (intermediate servers) before getting to the destination
  • Time it takes to get to each hop
  • The IP and sometimes the name of each hop

TRACERT can reveal how the routes of your internet requests change depending where you’re accessing the web. It also helps with troubleshooting a router or switch on a local network that may be problematic.

8. POWERCFG: Power Configuration

Are you frustrated with how quickly your laptop seems to run out of power? It could be that your power settings are configured as efficiently as possible. There’s a windows CMD command called POWERCFG (power configuration) that can help. Run the command prompt as an administrator and type powercfg – energy to get a full power efficiency report.

This image has an empty alt attribute; its file name is image-12.png

The process can take up to about a minute, but when it’s done, you’ll see whether there are any warnings or errors that might help you improve the power efficiency of your system.

View the energy-report.html file to see the details of those errors and warnings.

9. SHUTDOWN: Turn Off Computer

The SHUTDOWN command is a pretty versatile command that lets you shutdown the computer but control the behavior of that shutdown. It’s commonly used as a scheduled task or part of an IT batch job after patches have been applied to a computer system.

Typing shutdown /i from the command prompt will initiate a shutdown, but it’ll upon a GUI to give the user an option on whether to restart or do a full shutdown. If you don’t want to have any GUI pop up, you can just issue a shutdown /s command.

There is a long list of other parameters you can use to do a log off, hibernate, restart, and more. Just type shutdown without any arguments to see them all.

//Force an immediate restart of the computer. (after NULL Second)
shutdown /r /t 0

//Force an immediate restart of the computer after 2minutes = 120 Seconds)
shutdown /r /t 120

// Force an immediate shutdown of the computer.
shutdown /s /t 0

10. SYSTEMINFO: System Information

If you need to know what brand of network card you have, processor details, or the exact version of your Windows OS, the SYSTEMINFO command can help.

This command polls your system and pulls the most important information about your system. It lists the information in a clean format that’s easy to read.

11. CHKDSK: Check Disk

While the SFC command only checks the integrity of core system files, you can use the CHKDSK command to scan an entire drive.

The command to check the C: drive and repair any problems, launch the command window as an administrator and type CHKDSK /f C:.

This command checks for things like:

  • File fragmentation
  • Disk errors
  • Bad sectors

The command can fix any disk errors (if possible). When the command is finished, you’ll see a status of the scan and what actions were taken.

12. SCHTASKS: Schedule Tasks

Windows comes with a wizard for creating scheduled tasks. For example, maybe you have a BAT file stored on C:\temp that you want to run every day at noon.

You’d have to click through the Scheduled Task wizard to configure this. Or you can type a single SCHTASKS command to set it up.

SCHTASKS /Create /SC HOURLY /MO 12 /TR Example /TN c:\temp\File1.bat

The scheduled switch accepts arguments like minute, hourly, daily, and monthly. Then you specify the frequency with the /MO command.

If you typed the command correctly, you’ll see the response, SUCCESS: The scheduled task “Example” has successfully been created.

13. ATTRIB: Change File Attributes

In Windows, you can change file attributes by right clicking on a file and finding the right property to change. However, instead of hunting around for the file attribute, you can use the ATTRIB command to set the file attributes.

For example, if you type: ATTRIB +R +H C:\temp\File1.bat, it’ll set File1.bat as a hidden, read-only file.

There is no response when it’s successful, so unless you see an error message, the command worked

Other Windows CMD Commands

 CLS  Clear the screen
 CMD  Start a new CMD shell
 COLOR  Change colors of the CMD window
 CURL  Transfer data from or to a server
 CALL  Call one batch program from another
 COMPRESS  Compress one or more files
 DEL  Delete one or more files
 DELTREE  Delete a folder and all subfolders

 ECHO  Display message on screen
 ERASE  Delete one or more files
 EXPLORER  Open Windows Explorer
 FIND  Search for a text string in a file

 MKLINK  Create a symbolic link (linkd)
 MOVE  Move files from one folder to another
 MOVEUSER  Move a user from one domain to another
 MSG  Send a message

 SET  Display, set, or remove session environment variables
 SETX  Set environment variables
 SSH  OpenSSH remote login client
 START  Start a program, command or batch file

 TASKLIST  List running applications and services
 TASKKILL  End a running process
 TSKILL  End a running process
 TYPE  Display the contents of a text file

 WHOAMI  Output the current UserName and domain

 

By Shabazz

Software Engineer, MCSD, Web developer & Angular specialist

Leave a Reply

Your email address will not be published. Required fields are marked *