Let’s learn the 13 Hidden Tricks of Windows 11 Command Prompt. As we all know, the command prompt is a window where we can execute commands to get the desired results. There are many more commands available to do an action. As in the advanced days, using the command prompt is very rare.
Command Prompt has many awesome features in it. Today people have forgotten the command prompt, which is included with the Operating System (OS). Do not forget that the OS comes with a command line interface. So Microsoft brought some improvements to Command Prompt.
The command prompt is not as powerful as Unix commands, but many tricks make the command prompt helpful to have with OS. The Command Prompt (aka CMD) can let you do some tasks that can not be done by the GUI interface. Check out the 53 Most Common Run Commands for Windows.
In this article, some basic tricks of command prompts are discussed in detail. The usage of the command is described clearly, and also sharing some tricks to remember. This shows file encryption, color changing, a list of drivers and programs, etc.
- How to Open Elevated Command Prompt in Windows 11
- Enforce Users to Enroll Devices with Intune Conditional Access Policies
Hidden Tricks of Windows 11 Command Prompt
Many valuable and interesting commands are available for users in the Command Prompt console. The Command lines to execute are listed below and discussed in detail.
- Use Command Prompt to Encrypt file
- Change the Background and Foreground Color
- Change Prompt Text
- Change Command Prompt Title
- Show a List of Drivers Installed in the Current PC
- Show a List of All Programs in the Current PC
- Commands to Hide Folder
- Generate Battery Health
- Abort Executed Command
- Show Directory Structure
- Command Output Copied to Clipboard
- Delete Temporary Files Using Commands
- Key Functions from F1 to F9
1. Use Command Prompt to Encrypt file
The most useful thing is that you can use the command prompt to encrypt your sensitive data. Encryption is a way to prevent others from accessing your data. Ensuring that your files are only with your access is very important. This command is used to encrypt your file on a Windows PC easily.
To do so, launch the command prompt, press Win Key + R, type CMD in the Run dialogue box, and press Enter. And your command prompt window launches.
Now, you can change your directory or choose a folder using the cd command and reach your designated folder or file you want to encrypt.
Once you have completed the process, execute the command Cipher /E and hit ENTER. This command encrypts all the files situated in the selected folder. The process is shown in the figure below.
NOTE: If you try to open the encrypted files, then it will normally open for you, whereas any other user is not able to view the files unless they login using your account. So be sure to set your password.
2. Change the Background and Foreground Color
The black background and white foreground feel boring to work on it. Some commands can be used to change as a user needs to change. To know the codes for the colour option, you need to launch the command prompt, type help color and hit Enter.
Color attributes are specified by TWO hex digits, the first corresponds to the background, the second the foreground. Each digit can be any from 0 to 8 and A to F, as shown in the image below.
Color Code | Color Name |
---|---|
0 | Black |
1 | Blue |
2 | Green |
3 | Aqua |
4 | Red |
5 | Purple |
6 | Yellow |
7 | White |
8 | Gray |
9 | Light Blue |
A | Light Green |
B | Light Aqua |
C | Light Red |
D | Light Purple |
E | Light Yellow |
F | Bright White |
If no argument is given, this command restores the color to what it was when CMD.EXE started. This value either comes from the current console window, the /T command line switch or from the DefaultColor registry value.
The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute the color command with a foreground and background color that is the same. The following image color 1c, 7a, and a is executed, which represents 1 and 7 represent background color.
The c and a represent the foreground color. If you enter a single color code, it default changes the foreground color only. That is shown in the image below.
3. Change Prompt Text
In the Command Prompt, the C:\user\username> is the default text of the prompt. It can be changed using some commands. Users can customize the prompt text. Launch the command prompt to change, type Prompt NEWNAME$G and hit Enter.
NEWNAME be replaced with the name you wanted to give, and the $G sign represents the > sign at the end of the prompt, the command executed in the image below. To change back to the original type, Prompt and hit Enter.
There are more options like the code $G available you can check the entire list. To check the list, type the help prompt in the command prompt and hit Enter, as shown in the image below. The prompt can be made up of normal characters and the following special codes shown in the table.
Code | Description |
---|---|
$A | & (Ampersand Sign) |
$B | | (Pipe) |
$C | ( (Left Parenthesis) |
$D | Current Date |
$E | Escape Code (ASCII Code 27) |
$F | ) (Right Parenthesis) |
$G | > (Greater-than Sign) |
$H | Backspace (erases previous character) |
$L | < (Less-than Sign) |
$N | Current Drive |
$P | Current Drive and Path |
$Q | = (Equal Sign) |
$S | (Space) |
$T | Current Time |
$V | Window Version Number |
$_ | Carriage return and linefeed |
$$ | $ (Dollar Sign) |
If Command Extensions are enabled, the PROMPT command supports the following additional formatting characters. The Code commands are listed below.
- $+ : Zero or more plus sign (+) characters depending upon the depth of the PUSHD directory stack, one character for each level pushed.
- $M : Displays the remote name associated with the current drive letter or the empty string if current drive is not a network drive.
4. Change Command Prompt Title
The Command Prompt is the title for the command prompt title bar, or if you open the elevated command prompt, then the title is the Administrator Command Prompt. But you can change the title from the title bar. This will help you when you are opening a lot of command prompt windows working at a time, the title looks different.
To change, you have to execute a simple command and type the title Name. Replace the Name with the name you want to give. The execution of the command is shown in the image below. Do not worry when you relaunch the command prompt, it shows its default title in the title bar.
5. Show a List of Drivers Installed in the Current PC
When you try to troubleshoot an issue or look for a list of drivers installed in Windows 11, there is a magic command to show the list. Launch the command prompt, type driverquery /FO list /v, and press Enter to do so.
You see, the list of drivers present in the system is shown with detailed information, as shown in the image. It shows the detailed information about each driver is listed below.
- Module Name
- Display Name
- Description
- Driver Type
- Start Mode
- State
- Status
- Accept Stop
- Accept Pause
- Paged Pool (bytes)
- Code (bytes)
- BSS (bytes)
- Link Data Path
- Init (Bytes)
Keep the drivers’ details in your systems output in a text file if you want. Then there is the command you may execute, type driverquery > nameofthepath\driver.txt. Here replace nameofthepath with the location as shown in the image below.
6. Show a List of All Programs on the Current PC
This is a cool trick to know the list of programs installed on your device. This is very helpful to find the list. To find the list launch the command prompt, type wmic product get name, and press Enter. Now the installed programs are listed as shown in the image.
You can uninstall any program from the list using a command. To do so, type wmic product where name=”AppName” calls uninstall /nointeractive (replace AppName with the program you want to uninstall) and press Enter. You can see the particular program uninstall successfully, as shown in the image below.
7. Commands to Hide Folder
There is a command to hide any folder in your device. To hide a folder, launch a command prompt and move to the location of the folder you want to hide. Then type attrib +h +s +r foldername and press Enter. The folder is hidden.
There is the command to unhide the hidden folder, launch a command prompt and move to the location for the folder you want to unhide. Then type attrib -h -s -r foldername and press Enter. The folder is now unhided, you can see it.
If you wish to know how many folders or files are being hidden by you or the system, type dir /AH and press Enter. Now you can able to find all the file details.
8. Generate Battery Health
Windows 11 lets you track vital stats related to the battery’s health. This includes details like factory specifications, full battery capacity, and the current capacity, and these are updated with each session. You can generate a report about these details by using a command, follow the steps below.
- Launch command prompt in Administrative Privilege
- Type cd C:\Windows\System32 and hit Enter
- Then type powercfg/energy and hit Enter again
It will take 60 seconds to enable tracing. It observes the system behaviour, analyzing the traced data. When the analysis is complete, it produces the report, as shown in the image below.
The report is now stored in the location C:\Windows\System32\energy-report.html. Go to the location and double-click on it to open. The Power Efficiency Diagnostics Report is presented as shown below.
9. Abort Executed Command
This is the best Command Prompt trick, and everyone should be aware of it. If you run a specific command but accidentally execute a different command, or you want to stop a command from running in the middle of it. To quickly stop the command execution, simply press Ctrl +C together, and the operation will be aborted instantly, as shown in the image below.
10. Show Directory Structure
Launch the command prompt window, type tree, and press Enter to look at a neat and precise directory structure. You can see the precise directory structure as shown in the image below.
11. Command Output Copied to Clipboard
If you have ever tried to copy the text from the Command Prompt, you must know that it is difficult. But, there is a simple trick: you can copy the output of any command that you want, directly to your computer’s clipboard, and you can then paste it into any text editor you want. Type any command and place a pipeline (|) clip.
tree | clip
When executing the command, you see strange things that nothing happen. But here, the details are copied to the clipboard of your device. Now you open Notepad and press Ctrl + V, you can find the details as shown in the image.
12. Delete Temporary Files Using Commands
If your system is running low on space and urgently needs to clear some trash out, get rid of temporary files on your PC. Then you can clean out temp files from your PC and regain an amount of space. Type del /q /f /s %temp%\* and press Enter, all the temp files are deleted.
There is another command is used to delete the temp files. But, this command needs to run in the Administrative Command Prompt. Type del /s /q C:\Windows\temp\* and press Enter.
You can also use both commands at a time, but again you need to open a command prompt in the Admin window, then type del /q /f /s %temp%\* && del /s /q C:\Windows\temp\* and hit Enter.
13. Key Functions from F1 to F9
All the function keys on your keyboard are also shortcuts for various Command Prompt functions. Here is the description of each function key on your keyboard works in the command prompt.
- F1: Tap or hold this key to retype your last command letter by letter
- F2: Copy the current command to a specified character.
- F3: Retype the entire previous line.
- F4: Auto-delete the current command to a specified character.
- F5: Retype the entire previous line and cycle through previous commands.
- F6: Enter the end of the file indicator into the command prompt.
- F7: Opens list of previously entered commands.
- F8: Retype the entire previous line, and it shows the command history from the start.
- F9: Enter the previous command by entering a number linked with that line.
I hope the information on the 13 Hidden Tricks of Windows 11 Command Prompt is helpful. Please follow us on the HTMD Community and visit our website HTMD Forum, if you like our content. Suggest improvements, if any, and we love to know which topic you want us to explore next.
Author
Alok is a Master of Computer Applications (MCA) graduate. He loves writing on Windows 11 and related technologies. He likes to share his knowledge, quick tips, and tricks with Windows 11 or Windows 10 with the community.