Top 31 Best Command Prompt Tricks Hacks & Codes You Should Try

Almost every Windows user knows about the existence of CMD or Command Prompt but very few know how it’s used. It can provide you with a variety of information such as battery life report (for laptop users), in detail info about the pc, complete directory of the pc and much more. So here I have compiled a list of 31 command prompt tricks hacks & codes every Windows 10, 8, and 7 users can use to their benefit.

Best Command Prompt Tricks Hack & Codes

1.) Run multiple commands at once

People from tech background knows about the logical operator “AND” and the symbol “&&”, same can be applied in cmd to execute multiple commands at once.

For example, we can open a calculator + notepad at once by typing- 


2.) See full PC driver list

Our pc contains a lot of driver lists and if you want to check whether you have any particular driver in the pc then just type “driverquery” and you will see a big list of all the drivers along with the name, type, module, etc. 

3.) Abort a command in the middle 

Suppose you want to execute a command and if it is keeping on loading and is not stopping you can type Ctrl+c and it will stop in between. 

Also Read: Keylogger Protection: How To Detect, Prevent & Remove Them

4.) Create Wi-Fi hotspot using your pc or laptop

It is one of my favorite command prompt tricks.

There doesn’t seem any reason to turn the laptop or pc into a hotspot but if any need arises we can do it simply by typing a few codes in cmd.

To turn a pc into a hotspot we need to first open Control Panel–> Change adapter settings–> Right click and go to Properties –> Sharing –> Click on “Allow other network users to connect through this computer’s internet connection“. 

Now open CMD with Administrator rights and paste the following code:

a.) netsh wlan set hostednetwork mode=allow ssid=Youthotspotname key=yourpassword

b.) netsh wlan start hostednetwork Now your hotspot will be enabled and ready for use. 

To turn off the hotspot enter: 

netsh wlan stop hostednetwork

Create Wi-Fi hotspot using your pc or laptop
Create a Wi-Fi hotspot using your pc or laptop

5.) Get help for any command

To get an in detail use of any command prompt command just type the command name followed by “/?” and it will list down all the different commands associated with that keyword. 

For example when we type “ipconfig” it will only list down the IP address of the pc but it can be used to renew all adapters, show detailed information about any compartment, etc. 

6.) Save the output of any command to a file

Suppose you want to share the computer problem with any technician or save the output of any command which is too big for example the output of “dir/s” seems like an endless display. 

You can save the output directly to the file of any computer by typing the code-

commandname > path

For example: ipconfig > f:lol.txt

Also Read: (6 Methods) That Can Protect Your Computer From Webcam Hacking

7.) Get a list of all the commands in CMD 

Type “help” in the cmd and a list of all the commands will be displayed.

8.) Rename any file 

To rename any file the syntax is: 

RENAME [drive:][path]filename1 filename2

filename1 is the file to be renamed and filename 2 is the name to be given to the filename1.

For example:

rename f:lol.txt hash.txt

9.) Replace any file with another file

To replace any file with other file the syntax is:

REPLACE [drive1:][path1]filename [drive2:][path2] 

[drive1:][path1]                  filename   Specifies the source file or files.
[drive2:][path2]                 Specifies the directory where files are to be replaced.

For example: REPLACE f:lol.txt f:lol /A

This command adds the lol.txt file inside the lol folder. 

Also Read: How to Blur an Image in MS Paint in less than 30 seconds | Face & Text

10.) Change the date

The syntax for changing the date is:

DATE [/T | date]

Type DATE without parameters to display the current date setting and a prompt for a new one.  Press ENTER to keep the same date.

If Command Extensions are enabled the DATE command supports the /T switch which tells the command to just output the current date, without prompting for a new date.

For example: 

date /T” will display only the current date.

date” will ask you set the date. To do it you need administrator permission.

11.) Change any file’s attribute

The syntax to change the file attribute is: 

Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I]
       [drive:][path][filename] [/S [/D] [/L]]

  +   Sets an attribute.
  –   Clears an attribute.
  R   Read-only file attribute.
  A   Archive file attribute.
  S   System file attribute.
  H   Hidden file attribute.
  I   Not content indexed file attribute.
  X   No scrub file attribute.
  V   Integrity attribute.
      Specifies a file or files for attrib to process.
  /S  Processes matching files in the current folder
      and all subfolders.
  /D  Processes folders as well.
  /L  Work on the attributes of the Symbolic Link versus
      the target of the Symbolic Link

For example: 

If I want to change the attribute of the lol.txt to read-only then the command will be

attrib +R f:lol.txt

12.) CD command

When typing the “cd” it moves the directory back to one directory. The “cd/” command takes back to the root directory. 

For example:

When typed cd the output is 
When typed cd/ the output is 

13.) Clear the screen

By now you might have typed or pasted a lot of commands in the cmd so if you want to clear the cmd screen and bring it back to the much cleaner screen type “cls” in cmd.

14.) Change the color of the CMD

The syntax to change the color is:

COLOR [attr]

  attr        Specifies color attribute of console output

Color attributes are specified by TWO hex digits — the first corresponds to the background; the second the foreground.  Each digit can be any of the following values:

    0 = Black       8 = Gray
    1 = Blue        9 = Light Blue
    2 = Green       A = Light Green
    3 = Aqua        B = Light Aqua
    4 = Red         C = Light Red
    5 = Purple      D = Light Purple
    6 = Yellow      E = Light Yellow
    7 = White       F = Bright White

If no argument is given, this command restores the color to what it was when CMD.EXE started.

For example: 

The command “color 0a” sets the background color to black and the font color to green.

How to change color in cmd

15.) COMP command

Compares the contents of two files or sets of files.

The syntax is:

COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]]

  data1      Specifies location and name(s) of first file(s) to compare.
  data2      Specifies location and name(s) of second files to compare.
  /D         Displays differences in decimal format.
  /A         Displays differences in ASCII characters.
  /L         Displays line numbers for differences.
  /N=number  Compares only the first specified number of lines in each file.
  /C         Disregards case of ASCII letters when comparing files.

For example: 

comp f:lol.txt f:lol101.txt /D

will compare two files and will display “Files compare OK” if files have the same content.

16.) Copy any one or more files to some other location using cmd

The syntax to copy files is:

Copies one or more files to another location.

COPY source [/A | /B] [+ source [/A | /B] [+ …]] [destination [/A | /B]]

source       Specifies the file or files to be copied.
/A                 Indicates an ASCII text file.
/B                Indicates a binary file.

destination  Specifies the directory and/or filename for the new file(s).

For example: 

xcopy f:lol.txt f:lol

It copies the lol.txt file to lol folder.

In case you delete an important file/s you can recover it using the Remo File Recovery Software.

17.) Delete any file or files using CMD

The syntax is:

DEL [/A[[:]attributes]] names
ERASE [/A[[:]attributes]] names

  names Specify a list of one or more files or directories.
    /A        Selects files to delete based on attributes
  attributes    R  Read-only files            S  System files
                H  Hidden files               A  Files ready for archiving
                I  Not content indexed Files  L  Reparse Points
                –  Prefix meaning not

For example: 

del f:lol.txt will delete the file.

In case you deleted any files using CMD by mistake you can use the Remo File Recovery Software to recover deleted files.

18.) Display all the directories 

The syntax is: 

Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] 

[drive:][path][filename] Specifies drive, directory, and/or files to list.

For example:

dir f:lol displays all the files inside the lol folder.

19.) Exit the CMD directly by typing “exit“.

20.) Find any text string in a file 

The syntax to find any text string is :

FIND “string” [[drive:][path]filename[ …]]

  “string”   Specifies the text string to find.
  [drive:][path]filename  Specifies a file or files to search.

For example: 

find “techk47” f:lol.txt

Note:  It is a case-sensitive command. 

21.) See the whole drive’s entire directory  

With the “tree” command you can see the complete directories on the pc. This command also gives an endless output so we can save the output of this command directly to any file by using the previous command. It is an awesome cmd commands trick to show yourself as geeky in front of your friends or family members. 

22.) Open any separate window to run any program 

The syntax is:

start “programname”

For example:

Start mspaint” will open MS paint.

23.) Change the time using CMD

The syntax is:

TIME [/T | time]

Type TIME with no parameters to display the current time setting and a prompt for a new one.  Press ENTER to keep the same time.

If Command Extensions are enabled the TIME command supports the /T switch which tells the command to just output the current time, without prompting for a new time.

For example:

typing “time” will display time and ask us to set any other time.

24.) Type “ver” to know the Windows version. 

25.) To Display the disk volume label and serial number,if they exist. Type “vol“.

26.) To know all the commands you typed since you opened the cmd then type “Doskey” it will show all the commands. 

27.) Scan your pc for any corrupted files 

Type “sfc /scannow” and it will scan the integrity of all protected system files and replaces incorrect versions with correct Microsoft versions.

28.) Check your laptop’s battery life

This is one of my favorite cmd commands tricks as it is very helpful in understanding the battery condition of your laptop.

Open CMD as an admin and type “powercfg /batteryreport” then it will show a message “Battery life report saved to C:WINDOWSsystem32battery-report.html.” now press “Windows+R” and type “C:WINDOWSsystem32battery-report.html“. This file will open in your web browser.

29.) Remotely shutdown your PC

The syntax is:

shutdown /s” to Shutdown your computer

shutdown /r” to Restart PC

shutdown /l” to Logoff 

shutdown /a“to Abort the shutdown process before the timeout

30.) Get a detail info about your pc using cmd

The syntax is:


It will display all the information about the pc such as OS Version, manufacturer, domain, network card, etc.

31.) See different computers on your network

Displays protocol statistics and current TCP/IP network connections.

The syntax is: 


The output displayed will be a list of all the connections your pc is trying to communicate with.

For example:

netstat -a 

will display all the active connections.


What is a default gateway IP?

A default gateway makes it possible for devices in a network to communicate with devices on another network. Whenever a user makes a request the request goes through the default gateway exits through a local network and then reaches the internet.

What do IPv4 and IPv6 mean?

IPv4 (Internet Protocol Version 4) is the fourth revision of the Internet Protocol (IP) which is used to identify devices on a network using an addressing system.
IPv6 (Internet Protocol Version 6) is also called IPng (Internet Protocol next generation) and it is the newest version of the Internet Protocol (IP) reviewed by the IETF standards committees to replace the current version of IPv4.

How do you say hello world in CMD?

First, open the notepad and then type the below code:
ECHO Hello World!
Now save the file as helloworld.bat.

How do I make my command prompt colorful?

To change the default colors of Command Prompt:
Open CMD.
Right-click on the app’s title bar.
Now click on Properties
Now click on the Colors tab at the top of the window.
Now you can change the screen text, screen background, popup text, and popup background.

Also Read: Best Gaming Glasses in 2022 (for Gamers and Office Workers)
                    Best Wifi Adapter for Gaming [PC/USB] 2022 (For Pro Gamers) 
                    Best Gaming Projector in 2022 [Reviews & Buyer’s Guide] 
                    Best Condenser Mic under $200 in 2022 with Buyer’s Guide
                    Best VPN Extensions for Chrome in 2022 (Ones that are safe)

2 thoughts on “Top 31 Best Command Prompt Tricks Hacks & Codes You Should Try”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.