Best Command Prompt Tricks Hacks & Codes

If you are done with basic commands of the command prompt (cmd) or you find cmd cool and looking for cool commands then you are on the right page.

Here I will share amazing command prompt tips hacks so you don’t look at the command prompt say way ever again.

If you are coming from a Linux background then you know commands are one of the best ways to use computers.

Personally, it gives me a positive wive using a computer like no one else is using. Generally, people are amazed when they find someone performing a certain task using a command prompt.

In 2021 GUI is much better than the command-based interface. However, still, there are certain tasks that either you can perform faster-using cmd or you can’t do without a command prompt.

Anyway, here are the best commands that I hope you will like. if you have any questions or query then let me know by the comment section. I will be happy to help you.

In case you are visiting imagediamond first time then don’t forget to visit other articles.

Best Command Prompt Tricks Hacks

Hide A Volume

I’m pretty sure that all of you must try this trick. If not then basically you can hide your hard disk drive from This PC/Explorer

Here are the steps to do that.

  1. Open cmd by pressing windows + R and then type cmd.
  2. type diskpart
  3. it will ask admin permission, click on yes.
  4. It will open new cmd window. Here type list volume
  5. It will display all the volumes available on your pc. Whatever volume you want to hide type select volume (letter) example select volume G.
  6. Now type remove letter (letter)
  7. Type exit, this will hide the volume from My/This PC

If you want to bring that volume again then follow the first 4 steps. When you will run the 4th command list volume. It will display all the volumes available on your computer.

Now Type select volume (number). Because the letter has been removed so we will use the number e.x. select volume 2

After that type assign letter, G. Oryou can type whatever letter you want to assign. Just make sure that no that letter should not be assigned to any other volume.

Fix Pen Drive

Have you ever gotten in trouble when you are unable to format your pen drive. There could be various reasons that you are unable to access the pen drive.

However, if there is something wrong with programming instead of actual hardware then you can fix it easily using the command prompt.

Generally, my pen drive size shrinks after to make it bootable for installing windows os on other computers.

Here is the way to fix that, Waring: Your will lose your data in this method.

  1. Open cmd and type diskpart.
  2. It will ask system permission click on yes. This will open another cmd window.
  3. Now type list disk. This will display the list of disk (first willl be your system drive)
  4. If you have multiple device attached to your system then you can guess pen drive number based upon the size.
  5. Now type select disk (number) e.x. select disk 2
  6. Then type clean. It will clean all parition from your pen drive so you can make new parition.
  7. Now type create paritiion primary
  8. list parition. It should display only one parition
  9. then type format fs=fat32 quick
  10. And Finally exit

It should fix your pen drive problems. If this didn’t fix then something wrong in Pendrive physically.

Hack Router

If you are connected to a wifi network then what if you can hack the router and play with it such as

  • Changing password
  • blocking specific devices
  • turning it off
  • Or whatever you want to do

A Few months ago I have published an article on this. You can read here

Communicate With Another Pc

Imagine what if you can send and receive messages from one pc to another pc using the command prompt.

To use this trick make sure both computers should be connected to the same network. Here are the commends.

Type msg /SERVER:PC * /TIME:60 “This is the message to be sent to a PC named DestinationPC and closes in 60 seconds.”

Here replace the PC with the computer’s user with whom you are trying to communicate. if you want this message to show for a longer time then change TIME:60 to whatever value you like.

Create undeletable folder

To do this, first of all, run cmd as administrator. In the windows search type cmd. Then right-click on the cmd from the list and select Run as administrator.

Inside the cmd first of all go to what specific location where you want to create an undeletable folder.

You can jump between folders by typing cd full_path. For example, cd C:\Users\Kingdom\Desktop is the path of the Desktop folder. Here Kingdom is the username of my computer. It will be different in your case.

You can switch between volumes by typing d:. This command will take me to d: drive.

Anyway, once you are at the desired location then type md con/

Here md means make directory. con is a special keyword in Windows that can’t use for making folders unless you have administrator rights.

Shutdown Computer

You can also shut down the computer using cmd. Here are the commands to shut down or restart your computer.

To Shut down your computer shutdown /s
To Restart your computer shutdown /r
To log off computer shutdown /l

Function Keys

F1,F2…F12 has its own function the command prompt. Here is the list of them

F1: Repeat the letter of last command
F2:  It will display a dialog asking user to "enter the char to copy up to" of the last command line
F3: Repeat the last command
F4:  Display dialog asking for "Enter the char to delete up to" of the last command line
F5: Repeat the last command (Similar to the F3)
F6:  Enter ctrl+z (^Z) 
F7: prompt cmd commands
F8: Cycle back through previous commands
F9: Prompt asking user to enter the command number to repeat any command from history
F11: Full Screen More

Compare And Check The Difference

using fc you can compare two files. Here is the syntax to compare the two files.

fc filepath1.txt filepath2.txt

You can use the following arguments to get custom output.

/b This will perform binary comparison
/c It can be used for case sensitive comparison
/a It will only compare first two lines
/u It can be used to compare the unicode text files
/l it will compare files as ASCII text
/n This switch can only be used with ASCII but it will show all the corresponding line numbers
/t it will ordre fc not to expand on tab & spaces
/w it will compress white spaces during its comparison

E.x.

fc /a C:\Users\USERACCOUNT\Downloads\file.txt C:\Users\USERACCOUNT\Downloads\file2.txt

If you want to compare two text files then you can compare them using cmd.

Automatically complete commands using the tab

Another crucial tip for cmd lovers is to use a tab to complete your commands. Basically, once you typed the first two-three characters then press the tab it will automatically complete the command.

Not only command when you are typing path you can also use tab to autocomplete. You just need to type the initial characters.

The more you play with it more you understand how the tab works

Customize Command prompt (color, opacity etc)

You can customize the command prompt as you like. All you need to do is open the cmd, right-click on the title bar, and choose properties

It will open properties where you can control so many things such as

  1. font family & size
  2. color
  3. opacity
  4. etc

Here is my customized cmd. I have increased the font size, change the screen color, and decreased opacity.

Cmd tips & tricks

Try Alternative Powerful Solution: Windows Terminal

Windows terminal that has been recently introduced in Windows 10 is really cool feature introduced by Microsoft.

If this is not available in your computer then you can download it from the windows store.

In the windows terminal, you can do really cool things that are not possible inside cmd.

For example, you can open multiple tabs, run Linux commands, advance customization, and whatnot.

systeminfo

If you want to get information about your computer then systeminfo can provide all details that a normal computer user needs to know.

Just open cmd and type systeminfo it will display processor, memory, graphic card, time zone, etc information on your screen.

Find Hard Disk Size

You can’t find hard disk size by right-clicking on This pc then don’t try calculate by adding all volumes size.

There is an easy way. Open cmd type diskpart. It will ask for administrative permission. Click on yes.

Then type list disk. It will display all the storage devices attached to your computer. The first one will be your primary hard disk.

list disk

Rename Multiple Files

Does it ever happen to you that you have multiple files and you want to rename them? Using cmd you can rename all files with a single command.

First of all, go in that specific folder. Right-click anywhere and choose to open in the windows terminal.

Then type the following command

rename *.txt ???-Test1.*

Here * is a wild card that is used to represent perform an action on multiple files. Now it will perform an action on all files with an extension of txt.

? is also a wild card however it can original name of the file. We have used three question marks that’s why it will keep the first three characters of the file as it is and then insert -TEST1.

Control Another Pc

Yes, you can control another computer using cmd. However, to do this you need to change some settings in that particular computer.

Here are the instructions that you need to follow if you want to remotely control another computer.

Warning: This trick is shared only for educational purposes, do not miss use it to harm anyone.

Run Multiple Commands

If you want to run one command after another you can do it easily. use & for the next command.

Here is an example

ipconfig & notepad 

it will display all the network information and after that, it will open a notepad.

Find Windows License Key

If you thinking to reinstall the windows operating system then must get your product key if you have a genuine one.

To do this, in the windows search type cmd. The command prompt will appear. Right-click on it and select run as administrator.

then type the following command

wmic path softwarelicensingservice get OA3xOriginalProductKey

It will display your window key.

Final words

That was a lot. It took me 3 hours to research & publish this article. I want to publish unique commands that no one is sharing on the internet.

No doubt, cmd is one of the greatest tools available in windows. It can make a lot of things easier if you spend some time learning it.

I hope you got value from this article. If you are new to the imagediamond then don’t forget to read other articles.

If you have any suggestions or query then let me know by the comment section. I will happy to help you.

Leave a Comment

Pin It on Pinterest

Share This