Most Useful CMD Commands For Windows Users

CMD which refers to Command Prompt in Windows. It can help you run various commands provided by Windows OS to run for the administrator task, scheduling, scripts, batch files and troubleshooting problems.

While it might sound complex but there are many commands which can help you. For instance, you need to find the IP address of a website you might Google how to find the IP address of a website then try websites with lots of ads. But it can be done within your terminal in few seconds without any issues by using ping or nslookup.

This post covers very basic but useful cmd commands which you might end up using very frequently even if you don’t work in networking or system admin. All the commands listed aren’t case sensitive. Various commands accept extra options which can be case sensitive.

Do Not Mess with CMD
Do Not Mess with Command Prompt

How to Open Command Prompt [Multiple Ways]

If you are reading this post that means you already know how to open command prompt but still, there are multiple ways to do that maybe you can try a new way.

open cmd from run



  1. Windows Key + R → Type “cmd” → Hit Enter (For Admin rights Press Ctrl + Shift + Enter)
  2. Right Click on Windows Start Icon (Lower Left Corner) → Select “Command Prompt” or with (admin) or
    Windows Key + X → Select “Command Prompt

How to Customize Your Command Prompt


By using this command you can change the title of your current command prompt window.

You must be thinking what’s the need for this?
Well, while working there are the situation when you run a command it will start something for which you need to keep it running.

For running additional commands you need to open a new command prompt window.
So you might end up with 4-5 windows.
If you set the title of the window in the starting you can easily identify which window is doing exactly what.

TITLE My new Title
title /? – Check all available options



By default when you open any command prompt window the colour will be a black background with white text.

custom color in cmd

Try running color 07

You will notice nothing changes because this is the default one.
In the command, the first digit is for background, second for text colour
Type ‘color help’ to all the possible colours and combinations available.

Also, changing colour is just for your liking/customization and it has no effect on any other thing, colours set using this command is temporary and for that open command window if you want to set permanent colours for command window then right-click on command window > go to properties > colors tab.

change cmd colours permanent

Quick Tip: Opacity Control
If you are in a situation where you need to write commands from a webpage, keep an eye on another terminal what happening you can reduce the opacity of your current terminal by using the shortcut key
To Decrease the opacity: Ctrl + Shift +
To Increase the opacity: Ctrl + Shift + +

How to Navigate in Command Prompt

How to change directory

Go to root of your current drive with cd\


How to Switch to another drive

Use Drive Letter followed by a colon ‘:’ 
For Example, if you are in C Drive and you need to switch to S Drive you can do that by:


Go back one folder from the current location using cd..

S:/Your/pathName> cd..

Go inside one folder or multiple folders using cd

Inside one folder

S:/Your> cd pathName

Pass the path name with from current location

S:/Your> cd pathName/newfolder

Change Drive and go to a specific folder while switching drive otherwise, windows will take you to last visited location

cd /d S:/Your/pathName

Most Essential Commands


After lots of command testing or work command prompt gets messy with too many commands, to get the clean window you don’t need to close and start a new window just use the command cls to clear the screen.


Echo is one of the commands that everyone should definitely know because this command is pretty useful in many situations you probably don’t know like

Print variable value

echo %temp%
echo %path%
echo %computername%
echo %time%
echo %date%

Add text to file

Echo Some text to write to your file>FileName.txt

A new file will be created if the file does not exist and also file content will be replaced with new content

Play a sound

echo ^G

to type ^G press Ctrl+G on the keyboard don’t write or copy-paste it. This command will play BELL sound on windows can be useful in your batch file to play a sound when something important happens.


DIR is a great command to list all files and folders of any given location, you can list and sort output with various parameters to display exactly what you are looking for like display files and folder based on attributes with /A (hidden files, read-only files, archive files, folders or just files).

DIR/A:H (display hidden files)
DIR /A:A (display archive files)
DIR /A:HA (display hidden and archive files)
DIR /A (display all files)

You can sort the out of the DIR command with /O

DIR /A /O:N (sort by name)
DIR /A /O:S (sort by size)
DIR /A /O:GEN (sort by group folders, file extension and Name)

There are multiple more options that can be used to make output helpful like use /T to change display time from Last Written(default) to File creation or Last Access Time on output.

Hide Files and Folder using Command

Hiding files and folders is easy on windows you can use GUI version, right-click file or folder you want to hide go to properties and check hidden in general tab, If you want to use this that’s ok but if you want to hide files and folder selectively like hide all .mp4 in folder but not .mp3 or hide all folders that start with word new

Hide All Files with .mp4 extension

attrib +s +h *.mp4 (Hide)
attrib -s -h *.mp4 (Unhide)

Hide Folders and Files that start with word new

attrib +s +h new* /D (Hide)
attrib -s -h new* /D (Unhide)

Hide Files

attrib +s +h file_name (Hide)
attrib -s -h file_name (Unhide)

Hide Folders also with Files

attrib +s +h file_name /D (Hide)
attrib -s -h file_name /D (Unhide)

How To Change Date and Time on Windows using command prompt


Use Time command to set a new time of system or just display the current time, pass the current time with the following syntax

time HH:MM
time 12:13 pm
time 12:13 am

If you just want to know the current time using command then pass

time /T


Use date command to set a new date of system easily just follow the syntax

date dd-mm-yy
date 04-07-2019

To get current date use

date /T

If you are using automatic time and date sync feature in windows 10 then time and date set by you using command going to be overridden by windows 10 on next time and date sync.

sync time in windows 10

Useful Commands


As the command is itself explaining it will give you all the IP configuration of your computer,
Details like your local ipv6 and ipv4 addresses, Subnet Mask, Default Gateway, Ethernet Adapter info.

But if you add some extra options with the command it can do a lot of things

For example, if you are hosting a website and you change the DNS server of your website you need to flush your local DNS cache so you can get the new DNS server details

What you need to do is run

ipconfig /flushdns

It will purge all DNS resolver cache from your system

Here are all the options available that can be used with ipconfig {options}
Use the first help command to know in detail about usage.

ipconfig {options}

/? --> Display help message
/all --> Display full configuration information.
/release --> Release the IPv4 address for the specified adapter.
/release6 --> Release the IPv6 address for the specified adapter.
/renew --> Renew the IPv4 address for the specified adapter.
/renew6 --> Renew the IPv6 address for the specified adapter.
/flushdns --> Purges the DNS Resolver cache.
/registerdns --> Refreshes all DHCP leases and re-registers DNS names
/displaydns --> Display the contents of the DNS Resolver Cache.
/showclassid --> Displays all the dhcp class IDs allowed for adapter.
/setclassid --> Modifies the dhcp class id.
/showclassid6 --> Displays all the IPv6 DHCP class IDs allowed for adapter.
/setclassid6 --> Modifies the IPv6 DHCP class id.

If you only want to know your mac address you can use the command: getmac

NETSTAT: Active connection

Quickly view all your current TCP/IP active connection to find out which service is using what port.

By passing some additional flag you can customize the information. If you want to know which executable file is making that connection you can use -b and for interval just pass the value in numeric digits at the end of the command.

To view all the options in your terminal use netstat /? which will display the below options.

NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-x] [-t] [interval]

-a --> Displays all connections and listening ports.
-b --> Displays the executable involved in creating each connection or
listening port.
-e --> Displays Ethernet statistics. This may be combined with the -s
-f --> Displays Fully Qualified Domain Names (FQDN) for foreign
-n --> Displays addresses and port numbers in numerical form.
-o --> Displays the owning process ID associated with each connection.
-p proto --> Shows connections for the protocol specified by proto; proto
may be any of: TCP, UDP, TCPv6, or UDPv6.
-q --> Displays all connections, listening ports, and bound
nonlistening TCP ports. Bound nonlistening ports may or may not
be associated with an active connection.
-r --> Displays the routing table.
-s --> Displays per-protocol statistics. By default, statistics are
shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;
the -p option may be used to specify a subset of the default.
-t --> Displays the current connection offload state.
-x --> Displays NetworkDirect connections, listeners, and shared
-y --> Displays the TCP connection template for all connections.
interval --> Redisplays selected statistics, pausing interval seconds
between each display.


Ping command sends Internet Control Message Protocol (ICMP) echo request to destination target and waits for a response for every request sent and will give you statistics after completion like time took for a round trip, a packet sent, received and lost during the round trip.

Ping command is often used to check if your network printer is connected or not, so you know where to look for troubleshooting. Or use it to check if your computer can connect to another computer on a local area network or not.

By default ping command sends 4 requests you can increase the number of request by passing count with -n flag or you can use -t to run it until stopped.

Send ping request 10 times

ping -n 10

Send ping request until stopped

ping -t

Send ping request with packet size of 1000 bytes instead of default 32 bytes

ping -l 1000
ping /? - Check all available options

Pathping is a related command that gives more information you can use pathping if ping command does not satisfy your need

pathping /? - Check all available options

Quick Tip:
Some commands after running keep running and if you want to stop it use keyboard shortcut Ctrl+C
It will break the running process and you can run any command afterwards or Just open up new command prompt if you don’t want to break the process.


This is a very useful command for everyone especially for laptop users, you can use it to shut down, log off, restart and hibernate your local computer and remote computer. Another use case is if your power button is not working properly or any windows update broke power button then you can use this shutdown command.

There are some examples of the shutdown command

shutdown /s  - Shutdown without prompt
shutdown /i  - prompts
shutdown /r - Full shutdown and restart the computer
shutdown /l - Log off
shutdown /h - Hibernate computer
shutdown /t - Set timeout period after which system should shutdown or restart,
you need to define time in seconds,
max time you can set is 315360000 (10 years)
shutdown /? - Check all available options

To shut down after 15 minutes

shutdown -s -t 900

To restart after 15 minutes

shutdown -r -t 900


A must know to command everyone should know. The kind of useful information you get is exactly what you need in multiple scenarios detailed info of all the parts of your computer.

If some software doesn’t work or you are getting help from someone else or you are searching for help online people will usually ask the most basic system-level info of your computer which can be seen here easily.

Here is my system info I got to know in one command and is quite helpful for various problems :

Windows version with build number
Microsoft Windows 10 Home Single Language
10.0.18362 Build 18362

Processor Info
Intel 64 Family 6 Model 42 Stepping 7 Genuine Intel ~3300 MHz

BIOS Version
Intel Corp. BEH6110H.86A.0020.2011.0218.1538, 18-Feb-11

Details of current Hotfixes Installed
6 Hotfix(s) Installed.
[01]: KB4495620
[02]: KB4497165
[03]: KB4498523
[04]: KB4503308
[05]: KB4506933
[06]: KB4501375

Network Cards:
[01]: TAP-Windows Adapter V9
[02]: Intel(R) 82579V Gigabit Network Connection

Hyper-V Requirements :
VM Monitor Mode Extensions: Yes
Virtualization Enabled In Firmware: Yes

It’s super handy when you want to know the info of any computer instantly.

SFC: System File Checker

Windows OS comes with very useful commands to troubleshot file corruption problems like sfc, sfc (system file checker) check system protected file for corruption if corruption founds then tries to repair and replace with original files. For this most of the time user use command sfc /scannow, you need to run this command as an administrator.

sfc /scannow - Scans
sfc /verifyonly- Check the integrity only
sfc /scanfile=c:\windows\system32\kernel32.dll - Scan file and repair if required
sfc /verifyfile=c:\windows\system32\kernel32.dll - Only scan file, no repair performed
sfc /? - Check all available options

SCHTASKS: Schedule Tasks

This command can do wonders combined with some useful batch files or tasks.
It provides you ability to run certain programs, files on a specified date, time or interval.

It’s upto you what that task does, for example, you can take our batch file which we gave an example on our how to make your Windows boot time faster and schedule it to run on windows start what will happen is your boot time will be super fast and all your favourite programs will still be running without slowing down your boot up.

Using this command can look a little complex as it requires multiple options for creating scheduled tasks.

To know various parts in detail use /? after any parameter to get more help. Try running any of these commands they will get you more information (always remember reading more is good)

SCHTASKS /Create /?
SCHTASKS /Delete /?
SCHTASKS /Query /?
SCHTASKS /Change /?
SCHTASKS /ShowSid /?

An example of running a batch file hourly that is located in C drives temp folder with name File1.bat :

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


Often times you come across a situation where the software needs some specific drivers to work. In that case, you need to find is the driver installed and if it is then where it’s installed?

Simply Run driverquery it will list all the currently installed drivers of your local computer. To know the path where each driver is installed

driverquery -v

If you want to store that information into CSV file use driverquery -v /fo csv it will output data with comma-delimited.

To know all the possible combination use driverquery /?


You can get the list of running processes of your computer. You can even check running process of a remote computer too.

This command is useful because you can use this command to get the specific information you want like process using memory greater than or less than your specified memory. You can list the apps running on a remote computer, tasklist command offers various filters you can use with parameters some example here

List processes using memory greater than 100 MB. /fi is used to pass filter with command

tasklist /fi "memusage gt 100000"
you can use /fo to foramt your out like table, csv ot list
tasklist /fi "memusage gt 100000" /fo csv


Now you have a list of all the running process, you can use taskkill command to kill the process, the reason to kill the process using command are many like the programme is not responding or programme has a background service that is not stopped you want to kill all the services.

To kill any programme you can pass process id (PID) or image name with wildcard(*). You can kill task forcefully by passing /f with the command, also you have the option to use filters with /fi to make this command more powerfull like kill all apps using memory over 100 MB.

taskkill /FI "memusage gt 100000"
Kill Chrome
Taskkill /F /IM Chrome.exe
Kill process with pid 3125
taskkill -pid 3125


You can get any websites Domain Name System (DNS) infrastructure records with nslookup, even you can get specific record from DNS records like MX record or text record.

Find the IP address of a website


Find MX record of a website

>set q=mx



Non-authoritative answer: MX preference = 10, mail exchanger = MX preference = 20, mail exchanger = MX preference = 50, mail exchanger = MX preference = 40, mail exchanger = MX preference = 30, mail exchanger =

Find txt records of the website

> set q=txt



Non-authoritative answer: text ="docusign=1b0a6754-49b1-4db5-8540-d2c12664b289" text ="docusign=05958488-4752-4ef2-95eb-aa7ba8a3bd0e" text ="v=spf1 ~all“ text ="globalsign-smime-dv=CDYX+XFHUw2wml6/Gb8+59BsH31KzUr6c1l2BPvqKX8=" text ="facebook-domain-verification=22rm551cu4k0ab0bxsw536tlds4h95"

More about nslookup on Microsoft’s website.


It will compare a set of files and displays the difference between them.
Comparing works differently depending on what extra parameter you use along with FC.

For Example:

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.

All the available options are:

/A Displays only first and last lines for each set of differences.
/B Performs a binary comparison.
/C Disregards the case of letters.
/L Compares files as ASCII text.
/LBn Sets the maximum consecutive mismatches to the specified number of lines.
/N Displays the line numbers on an ASCII comparison.
/OFF[LINE] Do not skip files with offline attribute set.
/T Does not expand tabs to spaces.
/U Compare files as UNICODE text files.
/W Compresses white space (tabs and spaces) for comparison.
/nnnn Specifies the number of consecutive lines that must match after a mismatch.


Find out all the current file association for each file extension. File Association means when a type of file is associated with a program to open by default when double-clicked. For example all the .mp3 files open through windows media player then .mp3 file extension is associated with windows media player.

A lot of time you might select the wrong program when you open new files for the first time but later on find it’s not the right program, well there is a GUI mode too but it can be done through command as well.

Running assoc will list all the association of your computer

To remove any specific extensions file association from a program just write

assoc .mp3=

By not providing any program name after equal to sign it will remove the current association. After if you click on any mp3 file it will ask to select which program.


This command helps in finding all the hops a request needs to go through until reaching destination specified by you either IP address or hostname of a website.

If we run tracert we will get the output as

Tracing route to []
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms 
  2     1 ms     1 ms     1 ms [] 
  3     1 ms     1 ms     1 ms [] 
  4    26 ms    28 ms    26 ms 
  5    26 ms    27 ms    27 ms 
  6    26 ms    27 ms    27 ms 
  7    27 ms    28 ms    28 ms [] 

Trace complete.

What it means is until reaching network request goes through 7 hops in which is our router then broadband service and is Google’s one of many IP addresses.

You can find all the available options through tracert /?

tracert command help


Robocopy stands for Robust File Copy for Windows and robocopy is actually robust command it has a long list of parameters you can use with it, some examples

Robocopy D:\source\data E:\destination\data

copy all directories excluding empty directories

Robocopy /S D:\source\data E:\destination\data

copy directories with empty directories

Robocopy /E D:\source\data E:\destination\data

for a complete list of options check

robocopy /?


Copy command is useful command is used to copy files from one location to another location in the same drive or different directories. Copy command can be used to copy multiple files using a wildcard.

Copy all .pdf from current folder

copy *.pdf E:\destination\

copy all files from the current folder

copy * E:\destination\

Copy important.doc files to a different folder

copy D:\source\important.doc D:\destination\


xcopy is an advanced version of copy that has some advanced options besides basic features copy command has like copy directories, exclude files of a director or all files with a specific extension, copy subdirectories with a tree structure.

copy for file
copy all files & directories excluding empty directories if destination folder don’t have directories then create them

xcopy /S /E /I D:\source\data E:\destination\data

if want to copy hidden files too then pass /H too. xcopy command gives you the option to copy files based on files modified date by using /D that helps in taking an incremental backup

Xcopy /D:01-06-19 /I E:\source E:\destination

Copies files that are newer in the source folder than destination folder

Xcopy /D /I E:\source E:\destination


Start a new command window, this can be useful if you want to execute something in a separate window or want to show something in a separate window. It can be used to execute a batch script and .exe too.
/k makes new window to stay after execution

start cmd /k echo New Window!

/wait waits for new command window close before continuing

start /wait cmd /k echo New Window!

It’s up to you, you can pass /MIN so new command window open starts minimised and with /MAX new command window will open maximised

Start command can be used to open file explorer with a specific path, like start will open file explorer with current direcotry path of command prompt, you can pass path with to open that path like

start S:my\path\to\folder


If you are writing a chained commands using && or in any other way and want your commands to add a gap between any two commands execution you can use timeout command, timeout command waits for specified time before continuing you can use many types of parameters with it like /T followed by number (-1 to 99999) to make it wait for that much seconds you can any time press any key to continue otherwise it will wait for that time. In case you specified -1 it will wait until you press any button.

timeout /t -1 /nobreak
timeout /t 5 /nobreak
timeout /t -1 
timeout /t 5

MKDIR or MD / RMDIR or rd

Create New Folder with name newfolder in the current drive or path

S:\>mkdir newfolder

MKDIR [drive:]path
MD [drive:]path

Remove the folder named newfolder from the root of S Drive

S:\>rd newfolder /s
newfolder, Are you sure (Y/N)? Y

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

Use /s if the folder is not empty and contains files or folders. You can also use /q if you don’t need confirmation of Yes or No to remove folder.


Lists all files and directory of current location if no specified path and drive is passed. This is very helpful when you want to know what files are in what folder without hopping around folder to folder, don’t try this on path where thousands of files and folder are available because then output of this command won’t be much useful for you.

list all directories of the given path,

tree S:\foldername
tree command list folders
List folders

list all directories with file name also

tree /F S:\foldername
use tree /? for to know more


Disk Administration and Partition a Disk, with diskpart you can troubleshoot your corrupted external storage drive that could be pen drive or hard drive, using diskpart you can manage your drive, you can create and delete partitions, volumes, extend a partitions storage, format drive, change files system.

You can use it to get basic information about your drive

list disk
select disk 0
list partition
list volume

diskpart command

This command can be dangerous if not properly used so if you want to know more about DISKPART command you can go to Docs Microsoft.


Try chkdsk command if your hard drive is giving you a hard time to know if its time to replace it. chkdsk checks logical and physical errors, chkdsk gives many optional switches you can use with chkdsk command but usually you only going to need /r and /r most of the time.

This command is timesaver because sometimes we think some of our apps are crashing because the app had some error but it can be due to bad sectors on the hard drive.

If you run chkdsk without any options it will run in a read-only mode where command does not attempt to correct any errors, you can pass /f with it to instruct fix the errors found on the disk, additionally, you can pass /r to check for bad sectors on hard disk and try to recover data.

Always make sure to run these commands after having a proper backup of your drives because in some cases if may act differently.

chkdsk - Check for errors but don’t fix errors
chkdsk /f - Scan disk and fix errors
chkdsk /r - Locate bad sectors on hard disk (implies /f)
chkdsk /? - Check all available options


Delete files using DEL command make sure to use it with caution in right directory otherwise you will end up losing your data, DEL command gives you many options like use /P so before deleting every file it will prompt for permission, use /A: with correct attribute to delete files based on their attribute like delete hidden files.

DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

For Example

Delete all files that have .jpg extension

DEL *.jpg

Delete all files that have word test in starting

DEL Test*.*

Delete all files

DEL *.*


Easily rename file or folder name

RENAME [drive:][path]filename1 filename2
REN [drive:][path]filename1 filename2

You can’t specify a path or drive name in the destination file.

If your terminal is in the path where the file or folder is which you need to rename you don’t need to pass the path you can simply write

S:\>rename currentfilename newfilename

All Commands

Task Name Run Command
Set COLOR of Window COLOR
Clear Screen CLS
List all directory DIR
Change attribute of file and folder attrib
Change Time on Windows TIME
Change Date on Windows DATE
Active Connection NETSTAT
Shutdown using command SHUTDOWN
Get system information SYSTEMINFO
System File Checker SFC
Schedule Tasks SCHTASKS
List all installed driver DRIVERQUERY
List task based on conditon TASKLIST
Kill Process TASKKILL
Find IP address of a domain NSLOOKUP
Compare files FC
Find file association for each file extension ASSOC
Trace a request TRACERT
Robust File Copy for Windows ROBOCOPY
Copy files COPY
Copy files and directories XCOPY
Open new command window START
Run commands one after another TIMEOUT
Create New Folder and Remove Folder MKDIR or MD / RMDIR or rd
List all files and directory TREE
Disk Administration and Partion Disk DISKPART
Check Errors in Hard Disk CHKDSK
Delete files easily DEL
Rename file or folder RENAME


We hope you have to find at least something new to try out and become more efficient if you are just starting out to learn commands. Now you know some of the best and useful cmd commands for windows you should read our post on best windows utilities.

The best part of using terminal or command prompt is you can do things little faster with just your keyboard.

Resource for Further Reading

Share on:

More to Read from Software

Let's Be Friends 🤘