Command Prompt is a command-line interface in Windows that has been around for a while. It does not have a Graphical User Interface (GUI), hence all commands and parameters entered are in plain text, known as cmdlets (pronounced as command-lets), and so is the output.
Since its initial release in 1987, Command Prompt has come a long way in terms of supporting various different Operating Systems, as well as the support and functions it can perform. Pretty much anything that can be done from the GUI in Windows 10 can also be performed using the Command Line Interface (CLI). In fact, many other helpful tasks, such as resetting the TCP/IP stack, are only possible through the Command Prompt.
Table of contents
- Command Prompt internal guide and tricks
- Customization and managing preferences
- Encrypt files on shared drive
- Create Wi-Fi Hotspot
- Hide folders
- Copy output to clipboard
- Open a specific directory inside Command Prompt
- Hide RAR files
- Enable and set password for any user account
- Reset firewall settings to default
- Restart Start Menu
- Clear print queue
- Reset Group Policies to default
- Restart Windows Explorer
- Check Windows activation status
- Turn hibernation off and on
- Fetch/Display information
- Closing words
One may ask themselves why use Command Prompt for operations that can be performed using the GUI? Well, certain tasks and operations take longer to access or to perform using the GUI. While the alternative for the same operation using CMD is much simpler than quicker. An example of this is using the gpupdate /force cmdlet to apply any changes made to the Group Policy instantaneously. Whilst with the GUI, one may require to reboot the computer entirely.
We are going to show you the most useful and handy cmdlets there are in Windows 10 for you to use while troubleshooting and performing day-to-day tasks.
Command Prompt internal guide and tricks
We are going to be sharing with you the different types of tricks and cmdlets to be used in Command Prompt to make your life simpler, and that you can perform certain tasks with ease. These tasks and operations have been divided into various categories for quick and easy navigation.
Launch Command Prompt with Administrative privileges
The first thing to learn is how to launch the Command Prompt with administrative privileges. Having administrative rights while inside Command Prompt is important as then you get elevated rights to perform certain tasks, which are restricted in standard mode.
If you are not logged in from the Administrator account in Windows 10, then you will need to deliberately launch CMD with the same privileges as the Administrator account.
You may launch the Command Prompt with administrative privileges by using the Ctrl + Shift + Enter shortcut keys when searching for Command Prompt in the Search Bar, or simply right-click on it and select Run as administrator.
You can also set it to always run in administrative mode, so you won’t have to deal with the extra clicks and shortcut keys each time. But let us warn you that administrative privileges within Command Prompt in the wrong hands could end up in disaster for you.
- To always run CMD with administrative privileges, right-click on Command Prompt in the Search Box and click on Open file location.
- Right-click on the Command Prompt highlighted icon and click on Properties from the context menu.
- Click on Advanced within the Shortcut tab in the Properties window.
- In the Advanced properties window, check the box next to Run as administrator, and then click Ok.
The Command Prompt will always be open with administrative privileges, regardless of the method you launch it. However, if in the future you wish to disable this feature, just return to the Properties window and uncheck the box next to Run as administrator.
Abort/Cancel command execution
Did you know? You can cancel in-progress tasks and commands in the Command Prompt without corrupting anything. This quick action can be taken if a task is taking too long to execute, or you have simply changed your mind not to follow through.
To abort an executed command, simply press the Ctrl + C shortcut keys during the execution of a previous cmdlet. This will stop the execution right then and there.
The highlighted portion in the image above illustrates at which point I press the Ctrl + C shortcut keys.
Scan and fix corrupted system files
Windows is able to repair itself by replacing older, corrupted files with fresher ones. A simple command within the Command Prompt allows you to scan, detect, and replace any such files in the OS drive.
Type in the following command and run it to do so. Note that this must be run with administrative privileges.
Get Help with commands
If you are uncertain about any cmdlets in the Command Prompt, you can get their complete details, as well as all the possible arguments that could be connected to the command. All you need to do is concatenate /? after the cmdlet, as in the example below.
Check past cmdlets
Command Prompt allows its users to check which commands have been entered into the CLI since it was launched. Many of us are aware that the Up arrow in CMD lets you scroll through the previously executed commands. This can be used to bring up and run the same commands again, or modify them and run a new command.
You can also use the following command to display all of the recent cmdlets that have been executed in Command Prompt.
The doskey /history command only allows you to view the commands that have been executed. However, you may press the F7 function key on your keyboard to bring up another window through which you can view and execute any command that has previously been entered, using the up and down arrow keys.
Highlight the command that you want to rerun using the arrows and press Enter to execute.
Customization and managing preferences
This section of Command Prompt cmdlets focuses on the individual preferences of each user and how they can customize them. This includes customization, both within the Command Prompt as well as other Windows GUI.
Change Command Prompt window color
You can change the background and text colors in your Command Prompt. Very few people know about this, and the ones that do usually do not personalize the Command Prompt as they spend very little time on it. It is a personal choice and many might think that customizing the Command Prompt is useless.
If you use Command Prompt frequently, then you ought to use it to the colors that suit your eyes.
- Launch Command Prompt and right-click on the title bar. Now click on Properties.
- Switch to the Colors tab, select the field that you wish to customize, then select the color that you want to change it to. Repeat this step to change the different fields of the Command Prompt, then click on Ok when done.
- Now close the Command Prompt and re-launch it.
You shall now see the new settings for the colors that you have made to the Command Prompt.
Change prompt text
The prompt text is the text on the left of each line within Command Prompt that illustrates the current working directory.
Some people might find this very boring and can change it using a simple command. However, we must warn you that changing the prompt text will no longer display the current working directory. If you are a person who knows what they are doing, this should not be an issue for you. Furthermore, the effects aren’t everlasting. The prompt text reverts to default when a new instance of Command Prompt is launched.
Use the following cmdlet to change the prompt text:
prompt NewPromptText $G
Replace NewPromptText with the prompt that you wish to have. The “$G” at the end adds a “>” at the end so that there is a gap between the prompt text and the cmdlets that you enter.
Change Command Prompt title
You may also change the title of the Command Prompt window. It is especially useful if you have multiple instances of Command Prompt running simultaneously. Or, you might as well just do it for fun.
Use the following command to change the Command Prompt window title:
Replace NewTitle with the title of your preference.
This portion of the article covers every useful command that has to do with your device’s network, whether it is only to display or configure.
Obtain complete network adapter information
A simple command in the Command prompt can give you all the basic information of each and every one of your network adapters. May it be physical or virtual, bridged or not, all information can be displayed related to it.
Enter the following command in Command Prompt:
This command lists all the network adapters along with their relevant information below each one. The list is as lengthy as the number of adapters on your PC.
This information can be useful to know what IP address your computer is assigned, what subnet it is using, what the MAC address of each of the adapters are, etc.
Reset TCP/IP stack
Your computer’s network might not be behaving normally, although the settings and configurations on the device are as they should be. In such scenarios, old stacks get corrupted and do not allow new ones to be updated. The only solution is to reset the TCP/IP stacks so that new ones are loaded, and the network starts behaving normally again.
Note that this process will erase all current configurations of all the networking ports on your device, which also includes all inactive ones, as well as the virtual network adaptors. Hence, they will need to be reconfigured once the process is complete. Moreover, the operation also requires a system reboot, therefore it is advised to save your data before proceeding any further.
Follow the steps below to reset the TCP/IP stack:
- Open Command Prompt with Administrative Privileges.
- Type ipconfig /release to remove current IP settings.
- Type ipconfig /flushdns to remove DNS cache.
- Type netsh winsock reset to reset Windows Sockets API cache.
- Type netsh int ip reset to reset TCP/IP stack cache. Do not restart the computer just yet.
- Type ipconfig /renew to request new IP settings from the server.
- Restart the computer.
You can then re-enter the configurations that were initially created and perform the online tasks as usual.
This category of Command Prompt’s most useful cmdlets focuses on the different tasks and operations one could perform while only using the Command Prompt. It discusses a variety of different objectives that can be achieved through different niches of commands.
You can encrypt files within a folder through Command Prompt so that they are only accessible to you. Other user accounts would not be able to access these files, neither through the Command Prompt nor through the Windows GUI.
- Launch the Command Prompt and then navigate to the location of the files you want to encrypt.
- Enter the following command to encrypt everything within the working directory.
You have successfully encrypted everything within the folder you ran the above command in. Currently, only your user account will be able to access the files, while other users will receive a prompt stating that the file(s) are inaccessible.
If you ever want to decrypt the same files, return to the same folder within the Command prompt and run the following command:
Create Wi-Fi Hotspot
Windows 10 allows you to create a Wi-Fi hotspot from your PC using the same network adapter that receives Wi-Fi internet signals. You can use this feature to convert a wired internet service to wireless and connect other devices to it, without having to install a dedicated wireless access point.
- To create a Wi-Fi hotspot, launch the Command Prompt with administrative privileges.
- Enter the following command to configure the hotspot’s settings:
netsh wlan set hostednetwork mode=allow ssid=<em>HotspotSSID </em>key=<em>HotspotPassword</em>
Replace HotspotSSID with the name of the SSID you wish to keep, and HotspotPassword with the password you wish to use to connect with the hotspot.
- Now enter the following command to enable the hotspot.
netsh wlan start hostednetwork
You have now successfully created a Wi-Fi hotspot using your Windows 10 PC. Connect your other wireless devices to the hotspot just like connecting to a regular Wi-Fi.
As we mentioned earlier, some objectives can be achieved through the Windows GUI as well as through the Command Prompt. Hiding folders is one of them. However, a folder hidden through the GUI will be visible again if the settings in the File Explorer are reverted to default. If you hide a folder through Command Prompt using the guide below. it can only be visible again through another command.
- To hide a folder, launch the Command Prompt with administrative privileges and navigate to the location where the folder exists.
- Now use the following command to hide a folder of your choice.
Attrib +h +s +r FolderName
Replace FolderName with the name of the folder you wish to hide.
You can now check and see if the respective folders will no longer be visible through the File Explorer. It has not been removed but only hidden. You can unhide the very same folder by entering the following command:
Attrib -h -s -r FolderName
Remember to replace FolderName with precisely what you used to hide it with.
Copy output to clipboard
The results displayed by the command in Command Prompt can be annoying to read. Not only is the font almost unreadable, but it is almost impossible to copy the whole output if it is lengthy. With this neat command extension, you can copy the output of any command to the computer’s clipboard, and then paste it to any text editor of your choice.
Just concatenate | clip to the end of any command to copy it to clipboard.
Note that this does not display any information in the Command Prompt any longer. Now open any text editor and paste the results using the Ctrl + V shortcut keys.
Open a specific directory inside Command Prompt
Often navigating within the Command Prompt to different directories can get tricky, especially if you want to reach a subfolder hidden inside many other folders. You can use this simple trick to open the Command Prompt directly within a specific directory.
- Use File Explorer to navigate to the folder you want to open within the Command Prompt.
- Now write cmd in the path box at the top of File Explorer, and press Enter.
- Command Prompt will now open and the path will already be set to the one you navigated to from the File Explorer.
Hide RAR files
Although the main function of this feature in CMD is to concatenate 2 or more basic files together, such as TXT or CSV files. However, the feature we are about to discuss can also be used to hide information within compressed folders by concatenating it with another image. Follow the steps down below to hide data within images:
- Launch the Command Prompt with administrative privileges and then navigate to the location where the .rar file is located. Note that the image to be concatenated must also be in the same location.
- Enter the following command while replacing the relevant information.
copy /b CompressedFolder.rar + ImageName.ImageExt ResultantName.ResultantExt
Replace CompressedFolder with the name of the archived folder you wish to hide. Replace ImageName with the name of the image you want to concatenate it with. Replace ImageExt and ResultantExt with the extension of the image (PNG/JPG). Replace ResultantName with the name of the image you want to hide your data in (end resultant image).
As in the example above, the compressed file by the name “TopSecret.rar” has been hidden by concatenating it with the image “Image1.jpg,” and then saved to a new image by the name “JustAnImage.jpg.”
Remember: Always place the compressed file first in the command. Placing it second would make it unrecoverable and the data would be lost.
Now if you try to open the image that has just been created, it won’t. However, opening it with an extraction tool, such as WinRAR, would make the hidden folder accessible again. To open it with an extraction tool, right-click the image, expand Open with from the context menu, and select the app to open it with.
You should now be able to access the hidden information that was initially in the compressed folder.
Enable and set password for any user account
Rather than using the Local Users and Groups Management Console (Lusrmgr.msc), you can activate and set/reset a password of any user account in Windows 10 through the Command Prompt. This is especially useful if you want to activate and enable password protection on the built-in Administrator account.
Note that this is only useful in activating already existing accounts and cannot create a new one.
Use the following command to activate an account through Command Prompt. Replace AccountName with the name of the account you wish to activate:
net user AccountName /active:yes
Now enter the following command while replacing SetPassword with the new password for the user account, and AccountName with the name of the account to change/set the password of:
net user AccountName SetPassword
In the example above, we have changed the password of the Administrator account to “itechtics.”
Reset firewall settings to default
One might need to reset their Windows firewall to default settings. This is mostly required when a user has modified the firewall policies to such an extent that it is now a clutter. In such a scenario, resetting the firewall settings is the best solution.
Enter the following command in Command Prompt to bring the Windows firewall to its default settings:
netsh advfirewall reset
The Start Menu in Windows 10 might often get stuck and not open, or even hang for long periods of time. One cannot simply reboot the entire computer to get the Start Menu running again. Here is a quick fix to restart only the Start Menu.
Launch the Command Prompt with administrative privileges and enter the following command to kill the Start Menu process.
taskkill /im StartMenuExperienceHost.exe /f
The process should re-run in a few seconds. In the case that it doesn’t, enter the command below to start manually.
Try opening the Start Menu now and the issue should be resolved.
Clear print queue
It is said that printers can sense the fear of the person sending the prints. The more urgent the job is, the more the chances of the print job getting stuck.
You can use this neat set of commands to unclog the pipeline of print tasks so that you can send a fresh job to the printer.
Launch the Command Prompt with administrative privileges. Then enter the following commands one after the other to clear the print queue:
net stop spooler
del %systemroot%\System32\spool\printers* /Q
net start spooler
The print queue should not have been successfully cleared and you can continue to send a fresh set of prints to the printer.
Reset Group Policies to default
Just like firewalls, Group Policies can also cause confusion when they are played around with. If you do not know what is wrong or do not remember which policy to revert to reverse the changes, the best solution is to reset them to their default configuration.
Enter the following set of commands in the Command Prompt one after the other, reset all of your Group Policies and implement the changes made instantaneously, without rebooting the computer.
RD /S /Q "%WinDir%\System32\GroupPolicy"
RD /S /Q "%WinDir%\System32\GroupPolicyUsers"
Restart Windows Explorer
Often when changing the System Registries, the computer needs to be restarted. However, sometimes, just restarting the File Explorer is sufficient to make those changes. Here’s how you can reboot Windows Explorer through Command Prompt:
- Launch the Command Prompt with administrative privileges.
- Enter the following command to kill Explorer:
taskkill /f /im explorer.exe
- Once it successfully runs, enter the following command to restart the process:
This can also be done when the Explorer hangs or becomes unresponsive.
Check Windows activation status
You can check whether the Windows version is activated or not through a simple cmdlet. This is especially useful when purchasing a new laptop, and you need to make sure that Windows is genuinely activated and not pirated.
Enter the following command in Command Prompt:
You will get a pop-up dialog box stating the status of your OS. If it says “This machine is permanently activated” it means that the Windows is activated. If it states “Windows is in notification mode” it means that Windows is not activated and you need to enter a valid license.
Turn hibernation off and on
Hibernation mode is a method of saving power while ensuring that everything in the session remains open and accessible at the time of the wake. However, some people like to switch it off entirely as they do not use it. Moreover, disabling it also frees up space in the boot drive as the hibernation file stores large amounts of data from the last session.
Enter the following command in Command Prompt with administrative privileges to turn off hibernation.
powercfg -h off
If at any point you wish to enable it, use the command below:
powercfg -h on
This section discusses the different cmdlets that can be used to obtain and display various kinds of information onto the CLI.
List and uninstall programs/ applications
You can display all of the programs and applications installed on your PC directly in the Command Prompt. By obtaining the correct name, you can also proceed to delete them from Command Prompt as well. Here is how to display all the programs.
Enter the following command:
wmic product get name
Now that you have the right name for all the programs, you can delete any and all of them using the following command. Remember to replace NameOfProgram with the actual name of the program you wish to remove:
wmic product where name=”NameOfProgram” call uninstall /nointeractive
Check battery health
You can generate a complete battery health report for your laptop. This is an essential trick everyone should know to ensure that your battery doesn’t give up on you in the middle of an important task.
- Enter the following command in the Command Prompt with administrative privileges to navigate to the System32 folder.
cd /d C:\Windows\System32
- Enter the following command. This step might take several seconds to complete:
- The report has now been generated and compiled. You can access it by entering the following path and name of the HTML file in the Command Prompt:
The battery health report will now open in the default browser which can be used for a deep diagnosis.
Get local and remote PC serial number
Rather than physically opening up each computer to get its serial number, you can fetch it through the Command Prompt. This can be done on a local computer, and for a computer on the same network.
Launch the Command Prompt with administrative privileges and enter the following command to obtain the local CPU serial number.
wmic bios get serialnumber
Enter the following command to obtain a remote CPU serial number. Replace RemoteNameOrIP with either the name of the PC or its IP address.
wmic /node:RemoteNameOrIP bios get serialnumber
Get RAM serial number and capacity
Similar to fetching the PC’s serial number, you can also obtain information on how many RAM modules are installed on your PC, and what each of its capacity is. You can also obtain each individual module serial number.
Enter the following command in Command Prompt with administrative privileges to obtain the above-mentioned information:
wmic memorychip get serialnumber, capacity
In the above image, the 2 rows indicate that there are 2 RAM modules, each with a capacity of 4 GB. Note that the capacity is given in Bytes.
Get system uptime
In case you need to know how long the computer has been running, you can use the command below. This is especially helpful in identifying whether there was a power outage or not.
Enter the following command in Command Prompt to check when the computer was last booted up:
systeminfo | find “System Boot Time”
Get your public IP address
A private IP address can be configured at no extra cost, whereas a public IP address needs to be paid for, which is usually provided by an Internet Service Provider (ISP). To know your public IP address, enter the following cmdlet in Command Prompt:
nslookup myip.opendns.com resolver1.opendns.com
Command Prompt is an excellent utility, especially for power users. It lets you perform tasks quicker and more efficiently. As you may have learned, some tasks cannot even be performed through the GUI which the Command Prompt supports.
The list above states most of the cmdlets that can be used from day to day to perform numerous different tasks.