20+ Command Prompt Tricks that You Should Know

With an interface as attractive as Windows 10’s, it is easy to forget that the OS comes with a command line interface as well. You might have forgotten about Command Prompt, but Microsoft hasn’t, and it has brought some handy improvements to Command Prompt with Windows 10 and Windows 11. While it’s not as powerful as its Unix counterpart, there are many Command Prompt tricks that can make it a helpful tool to have. A lot of things that the Command Prompt (also known as CMD) can let you do are not even available in the GUI of the Windows OS, so it’s something you should be using. In this article, we have listed 20+ Command Prompt tricks that you should know in 2024.

If you’re new to Windows, we suggest glancing at our Windows 10 beginner tips article to get a better idea about how the OS works and its features. Now, let’s dive in and check out what you can do with Command Prompt.

1. Encrypt Files Using Command Prompt

One of the most useful things that you can do using the Command Prompt, is encrypting your sensitive data. Encryption is a way to prevent others from taking a peek at your data, and it’s a really important part of ensuring (to some extent, at least), that your files are only yours. With this simple Command Prompt trick, you can easily encrypt files on your Windows PC.

  • Launch the Command Prompt, and change your working directory to the folder where your files are. This can be done by using the “cd” command.
  • Once you’re done, type “Cipher /E“, and hit Enter. This will encrypt all the files that were inside the folder.
Command Prompt Tricks

Note: If you try and open these encrypted files, they will open normally for you, however, any other user will not be able to view the files, unless they log in using your account. So make sure that you have a password set.

2. Change the Color of the Command Prompt Window

The Command Prompt window can be unexciting with the default black background and light gray text color. But Windows does allow you to change these colors to suit yourself and make things a bit more intriguing.

  • Launch CMD and Right-click on the title bar
  • Click on “Properties” and in the separate window that opens, click on “Colors”`
  • Here you can choose the colors for the screen text or background as well as for the popup text and background, and also change the transparency of the CMD window
  • After you’re done choosing the most fitting colors for your personality, Click OK
Command Prompt Tricks

Note: There are a lot of other colors available, and you can check out the entire list by typing help color.

Command Prompt Tricks

3. Change the Prompt Text in Command Prompt

When you first open Command Prompt, the default text of the prompt is very boring. It does reflect the current working directory that the user is in, but it sure could use some customization. If you would like the prompt in your cmd window to say something other than the default, you can use the following trick.

  • Launch Command Prompt, and type “prompt” followed by the text that you want. Make sure you add “$G” to the end, to ensure that there is always the “>” sign at the end of the prompt, and you know where your command begins at.
Command Prompt Tricks
  • Hit Enter, and you will see the prompt in the cmd window change to your custom text.
Command Prompt Tricks

Note: There are some more options like “$G” available, and you check out the entire list by typing “help prompt“. Also, you can reset the prompt back to its original state by typing “prompt” and hitting Enter.

4. Change the Title of the Command Prompt Window

When you launch Command Prompt, you must have seen that the title bar reads “Command Prompt”, or maybe “Administrator Command Prompt”, if you launch it with Administrator privileges. While that is okay, but if you have a lot of cmd windows open, and each of them are working on a different task, then this “Command Prompt” title is not helpful at all. Fortunately, you can change that too.

  • Open Command Prompt, and type “title”, followed by the text that you want the Title bar to read.
command prompt tricks
  • Hit Enter, and you will see the Title of the cmd window change to the text that you entered.
command prompt tricks

Note: The title changes back to “Command Prompt” once you quit cmd and relaunch it. 

5. List Every Driver Installed on Your Windows 10 PC

If you’re trying to troubleshoot an issue or merely looking for a list of all the drivers on Windows 10/11, there’s a command prompt trick you can use. Follow the steps below to see the list of drivers:

  • Type in driverquery /FO list /v in CMD, and you will see a list of drivers on your screen.
cmd tricks driver list
  • If you want, you can also copy this output into a text file for easy viewing later. Use this command to save the drivers list to a document:
driverquery > C:\Users\YourUsername\Desktop\driver.txt

6. F1 to F9 Keys are Shortcuts in CMD

All the function keys on your keyboard are also shortcuts for various Command Prompt functions. Here’s what each function key on your keyboard does in CMD:

  • F1: Tap or hold this key to retype your last command letter by letter.
  • F2: Copies the current command up to a specified character.
  • F3: Retypes the entire previous line
  • F4: Auto-deletes the current command up to a specified character.
  • F5: Similar to F3, but lets you cycle through previous commands.
  • F6: Enters the EOF indicator into CMD.
  • F7: Opens a list of previously entered commands.
  • F8: Similar to F5, but doesn’t stop at the end of your command history in the session. Instead, it goes all the way to the start.
  • F9: Enters a previous command by entering a number associated with that line.

7. Hide Folders using Command Prompt

While there is an easy way to hide folders on Windows by using the properties pane of the folder and checking the checkbox that says “Hidden”, the method is not very useful as the folders hidden using this method can easily be viewed if the view options are changed to “Show hidden files and folders”, making it a pretty useless feature. However, just like you can hide folders using Terminal on Mac, using this cmd trick, you can hide your folders in such a way that they will be completely hidden, and Explorer won’t be able to display them at all. Simply follow the steps outlined below:

  • Launch Command Prompt, and navigate to the directory where your target folder resides.
  • Type “Attrib +h +s +r folder_name“, replacing the “folder_name” with the name of the folder that you want to hide, and press Enter.
Command Prompt Tricks
  • You can now check that the folder is indeed hidden inside Windows Explorer and can not be seen by anyone.
  • To unhide the folder, you can use the command “Attrib -h -s -r folder_name“.
Command Prompt Tricks

Note: Hidden folders can be viewed using the cmd command “dir /AH”.

8. Copy Command Output to Clipboard

If you have ever tried to copy stuff off the Command Prompt, you must have realized that it is exceedingly difficult, not to mention un-intuitive. However, with this 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 that you want.

  • Launch Command Prompt and type the command that you want to copy the output for, followed by “| clip“. For example, I’m using the command “ipconfig | clip“. Hit Enter, and you will see that the cmd window shows no output.
Command Prompt Tricks
  • Open a text editor, such as Notepad, and press Control + V, and you can simply paste the output of the command directly inside Notepad.
Command Prompt Tricks

9. List all Installed Programs

Another cool trick on the Command Prompt involves listing out all of the Windows 10 apps and programs that are installed on your PC. This is particularly helpful if you need to uninstall a program using the Command Prompt. To list out all the installed programs, simply follow the steps outlined below:

  • Launch Command Prompt, and type “wmic product get name“.
  • Hit Enter, and you will see a list of all the programs that are installed on your PC.
Command Prompt Tricks

You can also use wmic to uninstall programs, directly from the cmd window. Simply type “wmic product where “name like ‘%NAMEOFAPP%’” call uninstall /nointeractive” and hit Enter. Obviously, replace “NAMEOFAPP” with the name of the app that you want to uninstall from your PC.

10. Open CMD Window Inside a Directory

Let’s face it, the way Windows handles changing directories using the “cd” command is rather weird. Fortunately, there is a simple way to open Command Prompt windows inside a directory so you don’t have to change directories. This is a really handy trick, especially if the folders you want to access are buried deep inside the filesystem. To open a cmd window inside a directory, just follow the steps below:

  • Open the directory in Windows Explorer. In the address bar, type “cmd”, and hit Enter.
Command Prompt Tricks directory
  • A command window will open inside the directory you had opened in Windows Explorer.
command prompt tricks

11. Generate Battery Health Report

Windows 10 lets you track vital stats related to the battery’s health by maintaining data related to the battery. This includes stats like factory specifications, full battery capacity, and the current capacity and these are updated with each session. You can generate a report about these stats by using a CMD command, which can be executed as follows:

  • Launch Command Prompt as an Administrator or change directory using cd C:\Windows\System32
  • Enter command powercfg/energy
  • The system will take 60 seconds to analyze and then generate a report in form of an HTML documents
Command Prompt Tricks battery
  • To access the report, you can head to this location on your Windows 10 computer:
 C:\Windows\system32\energy-report.html
Command Prompt Tricks

As you can see in our laptop’s case, the battery’s capacity has dropped to 82% to what it was shipped with. If you want a step-by-step direction for generating battery health on Windows, click on the link to read the article.

12. Hide Sensitive RAR Files in Images

CMD facilitates a command which lets you concatenate or fuse two files into a single file. While this command comes in handy in merging the contents of basic file types such as TXT or CSV, you can also use the command to hide a RAR, ZIP, or another archived file inside an image or text file. To achieve this, follow these steps:

  • Open CMD in the directory which contains both files using the 10th item in this list or use the cd command to change the directory
  • Use command copy /b <RAR_filename>.rar + <image_filename>.<extension> <result_filename>.<extension>.
  • In our case, we used copy /b modules.rar+wave.png test2.png 
Command Prompt Tricks copy/b

Note: make sure you enter the RAR file first followed by the other file, else you won’t be able to recover the RAR package. The method also works on most common file types including documents and PDFs as long as you add the archive file first.

  • This will generate the result file, which in our case is test2.png

This PNG file displays as a normal image file but when you open it with WinRAR or any other extraction tool, it will extract the RAR file which is buried under the image file. This is a good way of saving your sensitive files from curious friends or co-workers or even prevent them from being misused even in case of a data breach.

13. Abort Command Execution

This is one of the best Command Prompt tricks and everyone should know about it. Say, you want to run a specific command but accidentally execute a different command. In that case, to quickly stop the command execution, simply press “Ctrl +C” together and the operation will be aborted instantly.

13. Abort Command Execution

14. Always Run Command Prompt as Administrator

For users who deal with system files and applications know that they always need elevated privileges to tweak and move around things. But on the other hand, Command Prompt always defaults to the normal account which makes it harder for users to gain Administrator access in the middle of an operation. So to save yourself from such situations, you can change the behavior permanently and run Command Prompt with Administrator privilege always.

  • Just search for “cmd” in the Start menu and right-click on it. After that, open its file location.
  • Now copy the Command Prompt shortcut to your desktop.
  • Move to desktop and right-click on the shortcut and open “Properties”.
  • Here, click on Advanced and enable “Run as administrator”.
  • Now onwards, open CMD from the desktop shortcut and it will always start with the Administrator privilege.
14. Always Run Command Prompt as Administrator

15. SFC /Scannow

SFC (System File Checker) is a relatively new addition to Command Prompt to keep your computer clean and bug-free. It’s a handy command-line tool that will help you fix many system issues. Just run sfc /scannow on Command Prompt and it will start verifying the integrity of all protected system files. Further, it will also repair the damaged files wherever possible. So in the future, if you face any issue, make sure to run this command on your Windows computer.

15. SFC /Scannow

16. Find Information About Commands

Sometimes we run a command to achieve a certain task, but don’t know much about it. So to learn about specific commands, add /? at the end of any command, and hit enter. Command Prompt will give you a good overview of its usage and syntax. Take an example of SFC from the above point, type sfc /? and hit enter. It will tell you the sub-commands with examples, and what are the other commands related to SFC in a lucid language. This command is similar to the “man” command in Linux.

16. Find Information About Commands

17. Command Line History

Many users are aware of the ‘UP’ navigation key to move forth and back between commands, but circling back to previous commands that were executed way back is difficult. However, there is the doskey /history command to check all your executed commands in a chronological list. The con is you can’t select the commands and execute them instantly and will have to type it out manually, which is not the best solution.

As a result, if you want to quickly navigate through all your past commands with the ability to execute them immediately, just press the F7 key. You will get a separate window where you can choose a command and execute it then and there. It’s one of the best Command Prompt tricks. Keep in mind, some users need to press the “Fn” key along with F7 to trigger this action.

17. Command Line History

18. Delete Temp Files to Clear Space

If you’re running low on space and urgently need to clear some trash out, getting rid of temporary files on your PC might be the swiftest action plan. Here’s what you can do to clean out temp files from your PC and regain a considerable amount of space.

  • Use the command del /q /f /s %temp%\*
cmd tricks delete temp files 1
  • Use the command del /s /q C:\Windows\temp\* (requires admin privileges)
  • You can also use both the commands in one go by typing del /q /f /s %temp%\* && del /s /q C:\Windows\temp\*
cmd tricks delete temp files 2

19. Play an RPG Game in Command Prompt

Do you like playing role-playing games? If so, you should definitely check out Ateraan, which is a text-only role-playing game that works inside the command prompt on your Windows PC.

  • Type the command telnet ateraan.com 4002 into CMD and press enter. That will launch the game, and you can create your character and start your journey. GLHF!
play rpg games cmd

20. Move to Windows Terminal

Command Prompt is one of the oldest Windows programs, but recently Microsoft announced a universal command-line tool for Windows that integrrated Powershell, WSL, and Command Prompt at once place; The program’s called the Windows Terminal. One of the advantages of running Command Prompt in Windows Terminla is you get the ability to run multiple tabs to execute multiple commands in the same Window. If you’re wondering how to try out the new Windows Terminal, refer to our guide on the same.

18. Move to Windows Terminal

21. View a Directory’s Structure

Using the dir command to get an idea about the structure of a directory could be a hard affair since the command isn’t very presentable. Hence, if you want to look at a directory’s structure in a more neat and precise way, use the tree command. Here’s how the command looks.

tree
Tree command Windows command prompt tricks

The command will show you the structure of your default directory “C:” If you want to check the structure of other drives, use the drive letter followd by a colon after typing the command.

tree A:
comment Comments 74
  • Andrzej duda says:

    Ten trik wcześniej nie działał ale trzeba włączyć telnet i naprawde działa któs sie naprawdę postarał 🙂 polcam

  • Cyan Crewmate says:

    my hotspot isnt working im on my pc and is says ”The hosted network couldn’t be started.
    The group or resource is not in the correct state to perform the requested operation.”

    • gggg says:

      me too

      • GyanPadol says:

        try on cmd prompt
        1) ipconfig/flushdns
        2)ipconfig/renew
        3)ipconfig/registerdns

      • mohit says:

        Error: unrecognized or incomplete command line.

        USAGE:
        ipconfig [/allcompartments] [/? | /all |
        /renew [adapter] | /release [adapter] |
        /renew6 [adapter] | /release6 [adapter] |
        /flushdns | /displaydns | /registerdns |
        /showclassid adapter |
        /setclassid adapter [classid] |
        /showclassid6 adapter |
        /setclassid6 adapter [classid] ]

        where
        adapter Connection name
        (wildcard characters * and ? allowed, see examples)

        Options:
        /? Display this 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.

        The default is to display only the IP address, subnet mask and
        default gateway for each adapter bound to TCP/IP.

        For Release and Renew, if no adapter name is specified, then the IP address
        leases for all adapters bound to TCP/IP will be released or renewed.

        For Setclassid and Setclassid6, if no ClassId is specified, then the ClassId is removed.

        Examples:
        > ipconfig … Show information
        > ipconfig /all … Show detailed information
        > ipconfig /renew … renew all adapters
        > ipconfig /renew EL* … renew any connection that has its
        name starting with EL
        > ipconfig /release *Con* … release all matching connections,
        eg. “Wired Ethernet Connection 1” or
        “Wired Ethernet Connection 2”
        > ipconfig /allcompartments … Show information about all
        compartments
        > ipconfig /allcompartments /all … Show detailed information about all
        compartments

  • mera naam says:

    how to do this???????????

    • Craddy says:

      Press the windows key and R at the same time. Then put in “cmd” in the text bar, and boom, you’re in

  • foot says:

    hello guys i saw the comments i will not use tracepath or bad commands

  • JPOICOGNITO says:

    If you try to do starwars trick go into command center or watever its called and turn on telnet

  • INCOGNITO says:

    The star wars movie trick ain’t working.

    • llama33 says:

      you have to turn on telnet first

    • naam jaan ke kya kro ge says:

      MAN what u have to do just enable telnet feature in control pannel from trun off on windows features then you can acces it

      • mera naam says:

        @naam jaan ke kya kro ge:
        how to do this

      • naam to ham jann chuka hai says:

        by the way nyc name

      • wario says:

        MAN I am actually PEE

  • SandeepKothari says:

    Marvel-ous!

  • mister me!!! says:

    when I tried to watch a new hope it said ” ‘telnet’ is not recognized as an internal or external command, operable program or batch file.” please help.

    • Virus_Creator says:

      Me Too

    • TyTy says:

      You have to download telnet from features then you can do it

  • SAM says:

    THANKS SIR IT WORKS

  • asd says:

    sfsdf

  • Syxvax says:

    How to remove that cipher/e command , I mean how do I decipher it

    • Ankit Nayak says:

      cipher/d

      • thesurajrajput says:

        kya hota hai esee

  • arssy says:

    thanks beebom your the best send more pleeeeeeeeeeeeeeeeeese

  • Lilly says:

    Great !!! lol

  • Jackk says:

    Lol, Thanx. This was helpful

  • AJ says:

    Great !!!

  • harshana says:

    >attrib -r -a -s -h /s /d
    try this one in side the folder
    – id show and + is hide

  • Sairaj Das says:

    How to change the Prompt Text in Command Prompt permanently?

  • Abdullah Mwale says:

    there all great but others don’t work on my computer

  • Yash says:

    This cool bt some command not working.

  • 47 says:

    if the telnet dose’nt work:go to the control panel/programs and features/turn windows features on or off/and turn on telnet service and then go back to the cmd and write the code.

  • Tyson says:

    telnet not working

    • Aditya says:

      Mine too
      Its fake

      • Akshay Gangwar says:

        Hi Aditya,

        The Telnet command does work. However, you may need to enable Telnet from Control Panel if it’s not already enabled on your system.

      • almighty says:

        how do we enable telnet?

  • Luke Chikkala says:

    WiFi Hotspot isn’t working on my laptop.
    After I type “netsh wlan start hostednetwork” it says the following:
    ‘The hosted network couldn’t be started.
    The group or resource is not in the correct state to perform the requested operation.’

    What am I missing?

    • admin says:

      netsh wlan set hostednetwork mode=allow ssid=HotspotName key=Password
      you need to type this in and change “Hotspotname” to the name u want it to be and “password” change it to a password u want it to be

  • Nimesh says:

    Great list. Being a long time user favoring CMD didn’t knew some of these tips.

  • History Gaming says:

    The Starwars Cmd “telnet towel..blinkenlights.nl”Dosent Work It Just Says
    “Hello Hacker Anonymuse>telnet towel.blinkenlights.nl
    ‘telnet’ is not recognized as an internal or external command,
    operable program or batch file”

    • ratGT says:

      Telnet is not working because it’s not enabled by default (which was not mentioned in the guide).
      Anyway, in order to enable it, start the Command Prompt with administrator permissions, the type/paste the following command:

      dism /online /Enable-Feature /FeatureName:TelnetClient

      …and the telnet is enabled!

      • Paulo publit says:

        I have so still does not seems working

  • Xerus says:

    I cant use the “Attrib +h +s +r foldername” on folder with a space…

    • Akshay Gangwar says:

      If your foldername has a space, you just have to enclose it within double quotes, and the command will work.
      For example, if your folder is called “Test Folder”, you have to use the command
      attrib +h +s +r “Test Folder”

      Hope this helps!

      • Beebom fan says:

        Thanks it was also not working for me

      • Danish Dogra says:

        The command Attrib +h +s +r is not working. The folder did not hide. Can you please help me.

Leave a Reply