Most of us rely on the Graphical User Interface (GUI) as it’s more convenient than memorizing the traditional command lines. But one thing is certain—you can’t perform every task in the Windows GUI, and that’s when Command Prompt can be at your service.
This built-in command line interface can produce immediate outputs using simple commands with fewer computer resources. This way, you do not have to navigate through different windows just to get a single task done. With this program, you can perform advanced administrative functions or troubleshoot different Windows issues on your own!
In this article, I will discuss 50 commands you must know to master Command Prompt. But if you’re relatively new to this utility, I advise checking our beginner’s guide first.
Basic Commands
Before deep diving into the major commands, I’ll start with the basic ones. Whether you’re planning to use Command Prompt extensively or just for general purposes, these are going to be useful.
Command | Function |
cls | Clears the Command Prompt screen |
exit | Quits Command Prompt |
help | Provides help with a certain command |
cd | Moves you from one directory/drive to another |
clip | Copies the content to Windows Clipboard |
ver | Displays your present Windows version |
CLS
This command simply clears the Command Prompt screen. If you feel to clear up the working space after executing too many commands, it can be extremely helpful. All you have to do is type cls
and hit Enter.
Exit
If you’re planning to close the Command Prompt application, you do not require moving the cursor to press the Close button. Simply run the exit command and the program quits.
You can also use the /b
parameter to exit from the loaded batch script. This way, the main window remains open and only the batch file is exited. However, if you use the parameter outside the script, it will close the CMD app.
where error code specifies a certain number
Help
This command comes in handy if you come across any command and wish to know its function. It provides you with the syntax along with the different parameters (switches).
If you simply execute help, it displays a list of the common commands used in Command Prompt.
However, not all commands support this utility. In that case, you may use the /?
parameter and this should work for every command.
CD or CHDIR
It simply means ‘Change Directory’ and as the name suggests, it switches you from the current directory based on the specified path.
If you simply execute cd, it will just display the name of your current directory. Therefore, it’s important to learn the different parameters along with their functions and syntax:
Parameters | Functions | Syntax |
<drivename>: | Displays the drive along with the last directory location | cd <drivename>: |
<path>: | Takes you to the directory as per the specified location | cd <path>: |
/d | Changes directory | cd /d [drivename]: |
.. | Takes you to the previous/root directory | cd.. |
Clip
This command copies the output executed from a certain command into the Windows clipboard. In this way, you can directly copy the data into any other program.
It’s extremely useful to directly copy the text or script files without opening them. Here are the parameters associated with it:
Parameters | Functions | Syntax |
<command> | Copies the output of a certain command to the Windows clipboard | <command> | clip |
<filename> | Copies the content of a certain file | clip < filename |
Ver
Command Prompt offers the quickest way to view the version number of Windows using a simple command. This way, you can determine whether the latest Windows version is installed on your computer.
System Commands
Whether you’re trying to learn about your computer or perform some system-related tasks, the following commands can come in handy:
Command | Function |
powercfg | Controls power system settings |
shutdown | Logs off, restarts, or shuts down your computer |
driverquery | Displays all the installed drivers |
hostname | Displays the name of the computer’s host |
systeminfo | Displays detailed information about your system |
Powercfg
This Command Prompt utility allows you to control the overall power settings of your computer. Note that if you use it without the appropriate parameters, you’ll encounter an “Invalid parameters” error.
While there are plenty of parameters available, I’m only going to discuss the most common ones below. If you want to learn more, simply execute powercfg /?
.
Parameters | Functions | Syntax |
/list or /l | Displays all the available power schemes | powercfg /list or powercfg /l |
/deletesetting | Delete a specific power setting | powercfg /deletesetting <sub_guid> <setting_guid> |
/setactive | Makes a scheme active | powercfg /setactive <scheme_guid> |
/getactivescheme | Fetches your current power scheme | powercfg /getactivescheme |
/hibernate or /h | Used to enable/disable hibernation | powercfg /hibernate [parameter] |
/availablesleepstates or /a | Displays the available sleep states on your computer | powercfg /availablesleepstates or powercfg /a |
/devicequery | Displays those devices that meet the specified criteria (query flag) | powercfg /devicequery <queryflag> |
/deviceenablewake | Allows the specified device to wake the computer from sleep | powercfg /deviceenablewake <devicename> |
/devicedisablewake | Disables the device to wake the computer from sleep | powercfg /devicedisablewake <devicename> |
/lastwake | Displays the activity that last woke your system from sleep | powercfg /lastwake |
To learn the above commands in detail, I recommend executing the powercfg /? <parameter>
command.
For example, if you wish to know more about the /list
parameter, you can execute powercfg /list
.
Shutdown
Interestingly, you can turn off your computer using a single command on Command Prompt. Also, it’s possible to schedule the shutdown process as you desire.
Here are some common parameters that might be useful:
Parameters | Functions | Syntax |
/i | Opens up the Remote Shutdown dialogue | shutdown /i |
/l | Logs you out | shutdown /l |
/r | Restarts your computer | shutdown /r |
/a | Cancels the shutdown operation | shutdown /a |
/h | Hibernates your computer | shutdown /h |
/t xxx | Sets the time-out period before the shutdown | shutdown /r /t xxx |
/f | Ends all the applications and signs you out of the computer | shutdown /f |
Driverquery
Moving on, device drivers are integral components of a computer. If you seek information on them, we already have the Device Manager utility on Windows GUI.
However, if you wish to display detailed driver information while working on the command-line interface, you may simply type driverquery
and hit Enter.
Along with that, you can utilize the following parameters each having individual functions:
Parameters | Functions | Syntax |
/s <system> | Specifies the name and IP address of your computer | driverquery /s [system] |
/u <domain> <username> | Specifies the user’s credentials and can only be used after /s is specified | driverquery /s [system] /u [username] |
/p <password> | Specifies the user’s password and can only be used after /u is specified | driverquery /s [system] /u [username] /p [password] |
/fo | Displays the output in the specified format–table, list, or csv | /fo [table/list/csv] |
/nh | “No header”, meaning the header is not displayed (doesn’t work for /fo list) | driverquery /fo [table/csv] /nh |
/si | Displays signed drivers | driverquery /si |
/v | Displays verbose output (doesn’t work for signed drivers) | driverquery /v |
Hostname
This command prints the device name. If you’re unsure about yours or you’re trying to identify it on another computer, simply typing hostname and pressing Enter in the Command Prompt will display the result.
Systeminfo
Unlike the hostname command, this will print detailed information about your computer. Basically, it’s like launching the System Information application to check your PC specs.
Moreover, you can use the same parameters used in devicequery
(/s, /u, /p, /fo, /nh, /si, and /v) to print the output in your desired format.
Windows Troubleshooting Commands
If you’re facing a Windows-related issue, there could be several causes for it—corrupted drive, system files, images, or more. Usually, running useful troubleshooters and commands can fix the problem, and that’s exactly what I will cover in this section.
Command | Function |
chkdsk | Checks your disk drives to identify and fix possible errors or bad sectors |
sfc | Scans the system files to determine corrupted ones and replaces them with a cached copy |
dism | Manages Windows images |
msdt.exe -id DeviceDiagnostic | Starts Hardware and Devices troubleshooter |
CHKDSK
This command checks for the local disks on the computer and informs users about logical and physical errors. Note that fixing errors is only possible if you use the following parameters wisely.
Here, I have only discussed the common ones. But if you want to learn more, here’s a complete guide on how to run CHKDSK to repair and fix a hard drive.
Parameters | Functions | Syntax |
<volume> | Scans the specified volume | chkdsk <volume>: |
/f | Fixes errors on locked disks (otherwise it first asks you to dismount the volume and completes the scan once you restart your PC) | chkdsk /f |
/v | Displays path and name of every file for FAT/FAT32 disks and cleanup messages on NTFS | chkdsk /v |
/r | Fixes the physical disk errors and performs all the operations that the /f parameter does | chkdsk /r |
/x | Forces the volumes to be dismounted before performing the scan | chkdsk /x |
/i | A quicker way to scan for disk errors for NTFS drives | chkdsk /i |
/offlinescanandfix | Performs offline scans to fix disk errors | chkdsk /offlinescanandfix |
SFC
The Windows System File Checker (SFC) helps you repair corrupted Windows files. It works by replacing corrupted files, which can even optimize the computer’s performance.
Here are some of the most used SFC commands:
Parameters | Functions | Syntax |
/scannow | All system files are scanned and repaired | sfc /scannow |
/verifyonly | All system files are scanned (no repair) | sfc /verifyonly |
/scanfile<file> | The user-specified system file is scanned and repaired | sfc /scanfile=[file path] |
/verifyfile<file> | The user-specified system file is scanned (no repair) | sfc /verifyfile=[file path] |
DISM
This command starts the Deployment Image Servicing and Management tool to configure the features and packages of Windows images. There are plenty of DISM commands to use when troubleshooting Windows, including FFU, WIM, Imaging, and more. But I will only be discussing the common parameters.
For your comfort, we have already provided a detailed guide on running different DISM commands.
Parameters | Functions | Syntax |
/online | Targets running OS | dism.exe /online [parameters] |
/image | Specifies the path of an offline Windows image | dism.exe /image:<path_to_offline_image> |
/list-image | Displays all files and folders in the specified Windows image | dism.exe /list-image ImageFile:<path_to_image_file> |
/delete-image | Deletes the specified Windows image from the WIM file | dism.exe /delete-image /ImageFile:<path_to_image_file> |
msdt.exe -id DeviceDiagnostic
The Hardware and Devices troubleshooter is no longer available with the other troubleshooters in Windows Settings. However, the utility can find and fix related problems with all hardware components.
In Windows 11, you can launch it using the msdt.exe -id DeviceDiagnostic
command on Command Prompt.
File and Directory Management Commands
Managing files and directories on Command Prompt can be a little tricky. Nevertheless, here are some of the basic commands that can make your tasks a lot easier.
Command | Function |
dir | Displays all the files and folders inside a directory |
copy | Copies files within the directory or from one to another directory |
move | Transfers files from one directory to another |
del | Deletes a file or directory |
mkdir | Creates a new directory |
ren | Changes file name |
rmdir | Deletes an existing directory |
type | Displays content of a text file |
assoc | Modifies the file type |
fc | Compares two files and displays their differences |
attrib | Changes a directory’s attributes |
tree | Graphical representation of a directory structure of a specified path |
DIR
This command displays all the files and directories/subdirectories from the specified drive/directory.
Most users utilize this command to list the files and directories. This is possible by simply executing the dir command. Along with the listings, it also displays the volume’s label, serial number, and the total number of files and directories.
Apart from that, you can also utilize the following parameters:
Parameters | Functions | Syntax |
<drive> | Displays the files inside the specified drive | dir [drive]: |
<path> | Displays the files from the specified location | dir [path]: |
/b | Displays just the list of items without any additional information | dir /b |
/s | Displays all the files inside the directories, their subdirectories, and files | dir /s |
/w | Lists all the files in a wide format | dir /w |
/d | Same as /w but sorts them by column | dir /d |
Copy
As the name suggests, this command copies the files from one location to another. Note that it will just create a duplicate instead of moving it.
For example, to copy the example.txt
file from the D drive to the Example folder in the same drive, here’s the command I’ll use:
copy example.txt Example
Move
This command functions the same way as copy
. However, the difference is that it actually moves the file from one location to the other. It’s basically the cut-and-paste technique we use in Windows GUI.
For example, to move the example.txt
file from the D drive to the Example folder in the same drive, here’s the command I’ll use:
move example.txt Example
Del or Erase
Both the Del and Erase commands can be used to permanently delete a file. This means that you can’t retrieve the file back from the Recycle Bin.
For example, to delete the example.txt
file permanently, here’s the command I’ll execute:
del example.txt
MKDIR or MD
Both the MKDIR and MD commands are used to create a new directory (folder). You can do this in the present directory or even on another directory directly, meaning you do not require moving to that specific drive/directory to create one.
For example, if I’m in D drive and wish to create a new directory, here’s the command I’ll use:
mkdir MyDirectory
But if wish to create a new directory in a specific path, here’s what I would execute:
mkdir C:\Users\bishu\Desktop\MyDirectory
Rename or Ren
Ren or Rename command simply reconfigures the file or directory name. While doing so, make sure you do not duplicate the name with any other file/directory.
Taking the same example as above, here’s how I am going to rename the two files I had created earlier:
ren MyDirectory MyDir
ren C:\Users\bishu\Desktop\MyDirectory MyDir
RMDIR or RD
It stands for ‘Remove Directory’ and that’s exactly what the command does. You may also use a shorter command that performs the same action–RD.
Here are all the parameters for the RMDIR command:
Parameters | Functions | Syntax |
<path>\<dir_name> | Deletes the directory as per the specific path | rmdir [path]\[dir_name] |
/s | Deletes the directory along with all the files inside it (asks for confirmation) | rmdir /s [path]\[dir_name] |
/q | Deletes the directory along with all the files inside it (doesn’t ask for confirmation) | rmdir /q [path]\[dir_name] |
As an example, I’m going to show you how to delete the MyDirectory file that I created earlier:
rmdir MyDir
rmdir C:\Users\bishu\Desktop\MyDir
Type
This command is used to display a text file’s content on Command Prompt. This way, you do not have to navigate to a certain location, open the file, and again close it if not necessary.
You may skip [path] if you’re in the same directory as the text file.
Assoc
This command is used to display or manage different file name extension associations. Note that you require administrative privilege to modify the associations.
If you simply execute the assoc command, the command-line utility lists all the extensions along with their associated file types.
Also, you can check which file extensions are associated with individual file types. For example, you can find out all the extensions that are associated with ‘sysfile’ as shown in the below example.
Example:assoc | find “sysfile”
It’s possible to modify the associations too. You can associate any file extension to whichever file type you want.
Example: assoc .abc=sysfile
Lastly, you can even delete an association. However, you’ll need to restart your computer to apply the changes.
Example: assoc .abc=
FC
FC stands for “File Compare” and as it sounds, it’s used for comparing two files so that you can learn about their differences. As shown in the demonstration above, I have compared two text files to know the item difference inside them.
Here are some of the useful parameters for the FC command:
Parameters | Functions | Syntax |
/b | Comparison in binary mode | fc <file1> <file2> /b |
/c | Ignores the letter case during comparison | fc <file1> <file2> /c |
/n | Displays the line number | fc <file1> <file2> /n |
/u | Comparison of Unicode text files | fc <file1> <file2> /u |
/w | Ignores consecutive spaces when comparing | fc <file1> <file2> /w |
Attrib
This command manages the attributes for files and folders. You can set whatever attribute you wish—Hidden, Read-Only, System, and more. To set an attribute, use ‘+’ and to remove, use ‘-’.
Attribute Value | Description |
H | Hidden |
R | Read-only |
A | Archive |
S | System |
O | Offline |
I | Not content Indexed |
X | No scrub |
V | Integrity |
P | Pinned |
U | Unpinned |
B | SMR Blob |
Tree
If you’re wishing to view the subdirectories inside of a directory or a drive, the tree command will make it look graphically pleasing. It structures the document in an easy-to-view format. All you have to do is run the tree command and specify the path if required.
Below are the two parameters you can adopt with the tree command:
Parameters | Functions | Syntax |
/a | Displays the lines using text characters instead of graphical representation | tree <path> /a |
/f | Displays all the items in the drive/directory | tree <path> /f |
Disk/Drive Management Commands
Along with file and directory management, it’s also possible to configure disks and drives in Command Prompt.
Here are the 7 most used commands for this purpose:
Command | Function |
vol | Displays the disk volume’s label and serial number |
format | Formats a certain drive in the specified file system |
diskpart | Manages storage drive partitions |
defrag | Defragments the specified hard drive |
diskusage | Displays the amount of used and free space available on the specific disk |
Vol
This is a command to quickly check the volume name or serial number. All you have to do is execute vol
with the drive letter.
Format
While there already exists easy-to-use GUI applications for formatting your disk drives, it’s never a bad idea to learn this on Command Prompt.
If you want to format a hard drive having just one partition, the format command should work out for you. However, the better option would be using diskpart
, which I shall discuss below.
Here, I’ll only mention the common parameters. Nonetheless, you can go through the other guide that should help you format a hard drive from CMD in detail.
Parameters | Functions | Syntax |
/v | Specifies the volume label of the drive you’re trying to format | format /v:<label> |
/q | Performs a quick format | format <drivename>: /q |
/fs | Formats the drive with specific file system | format <drivename>: /fs:<filesystem> |
/p | Completely wipes the drive | format <drivename>: /p:<count> |
Diskpart
This is a command-line interpreter that offers disk management features on Command Prompt. With this utility, you can assign drive letters, manage the drive attributes, configure partitions, display disk information, format a drive, and much more.
Type diskpart
and this should launch the interpreter. However, you require administrative privilege to use it.
In the table below, I have mentioned the most used commands in Diskpart. If you wish to learn more about disk partitions using the diskpart
command, you can check out our dedicated guides for both HDD and SSD.
Command | Functions | Syntax |
list | Displays the volumes, disks, partitions, or virtual disks based on the parameter specified | list <volume/disk/partition/vdisk> |
select | Selects a volume, disk, partition, or virtual disk based on the parameter specified | select <volume/disk/partition/vdisk> |
create | Creates a volume, partition, or virtual disk file based on the parameter specified | create <partition/disk/vdisk> <parameters> |
assign | Assign a drive letter or mount point to the selected volume | assign <letter=[letter_number]/mount=[path]> |
format | Formats a disk | format <parameter> |
exit | Exits the Diskpart interpreter | exit |
Defrag
Defragmentation simply means reorganizing the data inside an HDD to achieve better performance (not recommended on SSD).
Like any other action, Windows already offers a dedicated utility.
However, if you wish to know this in detail, Command Prompt offers tons of parameters that should help you out. Note that this command requires administrative privilege.
Parameters | Functions | Syntax |
<driveletter>: | Defrags the specified drive (traditional defragmentation, default parameter is set to /d) | defrag <driveletter>: |
/a | Analyzes the selected drive | defrag <driveletter>: /a |
/b | Performs boot optimization on the selected drive | defrag <driveletter>: /b |
/c | Runs operations on all the volumes | defrag <driveletter>: /c |
/h | Runs operations in normal priority | defrag <driveletter>: /h |
/u | Prints the progress | defrag <driveletter>: /u |
Diskusage
This might not be the most used command but is definitely worth it. You can get the summarized details on the selected disk’s usage in no time.
Simply executing the diskusage
command should do the job (note that you need to open CMD as an administrator). Along with that, you can take a look at the following parameters that might be beneficial:
Parameters | Functions | Syntax |
/c | Displays the result in CSV format | diskusage /c <drive>: |
/h | Displays the result in human-readable format | diskusage /h <drive>: |
/s | Displays size for system files only | diskusage /s <drive>: |
Networking Commands
Unlike others, networking commands are widely used mainly for troubleshooting purposes. In fact, fetching IP addresses or configuring network settings is much easier on Command Prompt than using GUI components.
If you’re a networking enthusiast, here are the commands that you need to focus on:
Command | Function |
net | Manage network and its settings |
ipconfig | Displays detailed information about your network configuration |
netsh | Starts the Netsh prompt that lets you manage network configurations |
netstat | Displays active network connections |
ping | Verifies IP-level connectivity and reachability |
tracert | Checks the computer’s path to connect to the network |
pathping | Traces the route to the target and also displays the statistics (combination of ping and tracert) |
getmac | Displays the MAC address |
nslookup | Displays the information about domain names and IP addresses |
Net
You can use this command to manage different networking services. It comes with multiple options each performing a specialized task.
Here, I’ve only mentioned the most common ones. You can execute the net
command without a parameter to get more.
Option | Function |
accounts | Configures login requirements |
computer | Manages computers in the domain |
continue | Restarts a service |
start | Starts a networking service |
stop | Stops a networking service |
view | Displays all the devices in a network |
statistics | Displays network statistics |
Ipconfig
This command is for network configuration and management. You can view the detailed Windows TCP/IP information, release/renew IP addresses, flush the DNS cache, and much more.
Executing ipconfig
without parameters displays the IPv4, IPv6, subnet mask, and default gateway for every adapter. For other purposes, you can adopt the following parameters:
Parameters | Functions | Syntax |
/all | Displays TCP/IP configuration for all adapters | ipconfig /all |
/flushdns | Flushses the DNS client resolver cache | ipconfig /flushdns |
/release <adapter> | Releases the DHCP configuration for the specified adapter (you can simply execute the /release parameter to release the configuration for all the adapters at once) | ipconfig /release <adapter> |
/renew <adapter> | Renews DHCP configuration for the specified adapter (if not specified, renews for all the adapters) | ipconfig /renew <adapter> |
Netsh
This is another essential networking command used for managing network configurations. You can execute netsh
to launch the dedicated shell. After that, you can perform desired networking operations using some of the well-known parameters from the below table:
Commands | Functions |
dhcpclient | Manages the DHCP client service |
dnsclient | Manages DNS client settings |
firewall | Manages the Windows firewall service |
interface | Manages physical or virtual network adapters |
lan | Manages LAN settings on your computer |
wlan | Manages wireless network settings on your computer |
namespace | Manages namespace configurations |
offline | Sets the mode to offline |
online | Sets the mode to online |
quit/exit/bye | Exits the Netsh shell |
winsock | Manages Winsock settings |
Netstat
This command lists the active connections on your computer. It displays the protocol, local as well as foreign address, and the current state. Just executing the netstat
command will list the active TCP connections.
To display other protocols, here are some parameters you can use:
Parameters | Functions | Syntax |
-a | Displays all the active TCP and UDP connections | netstat -a |
-b | Displays all active connections along with each process (requires admin privilege) | netstat -b |
-e | Displays the interface statistics | netstat -e |
Ping
This command is widely used for testing host-server reachability and internet connectivity. Executing ping
displays the IP address statistics and the approximate round trips in milliseconds.
Here are a few parameters that I recommend trying out:
Parameters | Functions | Syntax |
-t | Continues displaying stats until interrupted by pressing CTRL+C | ping -t <target_name> |
-n<count> | Displays stats based on the specified number of echo Request messages | ping -n <number> <target_name> |
-l<length> | Displays stats based on the specified length | ping -l <number> <target_name> |
Tracert
This command traces the route to a certain IP or domain by sending ICMP or ICMPv6 messages with increasing TTL values. It’s extremely useful during network troubleshooting as it informs users about the routing issues and validates the network paths.
Implementing the tracert
command without a parameter traces the route of the specified domain/IP over a maximum of 30 hops.
Nevertheless, you could make use of the following parameters to gain additional networking information:
Parameters | Functions | Syntax |
-h<max_hops> | Displays results in ‘n’ no. of maximum hops specified | tracert -h <hops_in_number> <target_name> |
-d | Doesn’t resolve IP address making the results appear much faster | tracert -d <target_name> |
-w<timeout> | Specifies the maximum time to wait for echo Reply message (if not, displays *) | tracert -w <max_time> <target_name> |
-4 | Uses IPv4 to trace the route | tracert -4 <target_name> |
-6 | Uses IPv6 to trace the route | tracert -6 <target_name> |
Pathping
This command is a combination of Tracert and Ping. When executed without a parameter, it traces the route to the target over a maximum of 30 hops and computes statistics for 125 seconds (by default).
Here are some of the most used pathping
parameters:
Parameters | Functions | Syntax |
-h<max_hops> | Displays results based on the maximum hops specified | pathping -h <number> <target> |
-p<period> | Waits between consecutive pings before displaying the stats | pathping -p <max_period> <target> |
-w<timeout> | Specifies the maximum time to wait for each reply | pathping -w <max_time> <target> |
-4 | Only uses IPv4 | pathping -4 <target> |
-6 | Only uses IPv6 | pathping -6 <target> |
Getmac
If you wish to get the MAC address of your computer, you can execute the getmac
command and this will display the result in no time. The result includes both the physical address and the transport name.
Along with that, I highly recommend trying out the following parameters:
Parameters | Functions | Syntax |
/s <computer> | Displays the results for the specified computer name of IP address | getmac /s <computer> |
/fo <table/list/csv> | Displays in the specified format | getmac /fo <table/list/csv> |
/nh | Displays in the table or CSV format excluding the column header | getmac /nh |
NSLookUp
This is yet another command-line utility that includes numerous commands to obtain domain name or IP address information. To start the prompt, simply type nslookup
in the Command Prompt and hit Enter.
While there are countless parameters for nslookup
, I’m only going to focus on a few common ones in the table below:
Commands | Functions |
finger | Connection with finger server |
ls | Displays DNS domain information |
lserver | Changes default server to the specified DNS using current server |
server | Changes server to the specified DNS using default server |
set | Different parameters (all, class, d2, etc.) are used to set various DNS-related settings |
Miscellaneous
If you have implemented each of the commands I’ve discussed, you should now be proficient enough to use Command Prompt. However, the aforementioned commands are not enough to master this Windows command-line interface.
There are thousands more, and it’s impossible for me to include all of them in this single post.
For now, I would recommend trying out the following commands that could come in handy while you’re on the way to mastering Command Prompt:
Command | Function |
tasklist | Displays all the currently running processes |
taskkill | Kills a process |
powershell | Starts Windows PowerShell session |
set | Manages Windows environment variables |
start | Runs the specified program |
bcdboot | Repairs the boot environment |
date | Displays today’s date |
prompt | Changes the cmd text |
color | Customizes foreground and background color |
Tasklist
You can use this command to display the currently running processes on your computer. Executing tasklist
lists down the name of the process, its PID, session name, session number, and memory usage. Also, you can try out the following parameters:
Parameters | Functions | Syntax |
/s <computer> | Displays all the processes of the specified computer name or IP address | tasklist /s <computer> |
/m | Displays all the modules of currently running processes | tasklist /m |
/fo <table/list/csv> | Displays the results in a specified format | tasklist /fo <table/csv/list> |
/nh | Displays the results in table or CSV format without the header column | tasklist /nh |
/svc | Displays all the services associated with the currently running processes | tasklist /svc |
Taskkill
While the tasklist
command displays the processes, taskkill
kills/ends them. You can use either process ID or image name to do this task. Therefore, you need to utilize any of the following common parameters:
Parameters | Functions | Syntax |
/pid <processID> | Kills the process as per the specified process ID | taskkill /pid <processID> |
/im <image_name> | Kills the process as per the specified image name | taskkill /im <imageName> |
/f | Ends the process forcefully | taskkill /f <pid/im> <processID/imageName> |
/t | Ends the process along with all the child processes | taskkill /t <pid/im> <processID/imageName> |
Powershell
If you prefer Windows PowerShell over CMD, you can actually run the Command Prompt as a Powershell window. Just type powershell
and hit Enter. You’ll likely get the PS prefix indicating that you can now run all the Powershell cmdlets here.
Set
This command is used for configuring the Windows environment variables. To display all the available ones, you can use the set
command without any parameters. In order to set a new environment variable, you can use a variable name and provide the necessary value.
Likewise, it’s possible to delete any environment variable too. Below is the syntax that should clear your doubt.
The set
command on Command Prompt has the following two parameters with individual functionality:
Parameters | Functions | Syntax |
/a | Sets the variable name as a line of input | set /a <variable>=<expression> |
/p | Sets the value as a numerical expression | set /p <variable_name>=<promptString> |
Start
You can use this command to launch a new Command Prompt window. Without the use of any parameter, it will simply launch the new prompt. However, utilizing the following parameters can help you perform just more than that:
Parameters | Functions | Syntax |
“title” | Launches the CMD window with the specified title | start “<title_name>” |
/d <path> | Starts the CMD window with the specified path | start /d <path> |
<min> or <max> | Launches the CMD windows in restored or maximized window | start <min/max> |
/wait | Starts the application and waits for it to end (meaning you cannot execute further commands in the main prompt) | start /wait |
BCDBoot
Most users utilize this command to repair the boot environment from the Windows Recovery Environment. It works by copying the Windows installation files to a system partition. You need to execute bcdboot
with the following parameters:
Parameters | Functions | Syntax |
/l | Specifies an optional language during BCD store initialization | bcdboot <source> /l <locale> |
/s | Specifies the system partition’s label where the BCD files will be copied to | bcdboot <source> /s <partition> |
/d | Preserves the existing default windows boot entry | bcdboot <source> /d <path> |
/bcdclean | Cleans the BCD store | bcdboot <source> /bcdclean |
Date
This is another useful command to quickly check the current date. You can display or set a new date as per your requirement. If you execute just the date
command, the prompt displays the date and asks you to set a new one. But if you quickly want to check the date, use the /t
parameter.
Prompt
This command offers customization of the text that appears in front of the cursor (by default, it’s the current directory path).
You can change this to any character string of your choice or predefined characters (like current date, drive, path, times, windows version, etc.) using special codes. You can check using the /?
Parameter. To switch back to the normal format, execute the prompt without any parameters.
Color
Certainly, you have thought of customizing the Command Prompt. To your surprise, it’s possible to tweak the default black (background) and white (foreground/text) combination. For this, you require specifying two hex digits—the first representing the background and the second corresponding to the text.
Hex Digit | Color |
0 | Black |
1 | Blue |
2 | Green |
3 | Aqua |
4 | Red |
5 | Purple |
6 | Yellow |
7 | White |
8 | Grey |
9 | Light Blue |
A | Light Green |
B | Light Aqua |
C | Light Red |
D | Light Purple |
E | Light Yellow |
F | Bright White |
As per the above table, let’s say you want a red background with light blue text. So, you’ll have to execute the following command:color 49
While you’re at it, note that you cannot set the same background and foreground colors. Even if you do it, the command will not execute and you’ll be left with the existing combination.
To switch back to default, run the color command without any parameter.