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 user can use to their benefit.

 

command prompt tricks hacks & codes
31 Awesome CMD Commands Tricks You Never Heard Before

 

Best Command Prompt Tricks Hack & Codes

1.) Run multiple commands at once


People from tech background knows about logical operator “AND”
and it’s 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- 

calc&&notepad

2.) See full PC driver list


Our pc contains a hell lot of driver list 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 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 favprite 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 few codes in cmd.

To turn a pc into 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 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. 

Help command in cmd
Help command in cmd



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


Suppose you want to share the computer problem to 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.
  [drive:][path][filename]
      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 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 
font color to green.

How to change color in cmd
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.

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.

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 in 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 tricks to show yourself as a 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:

systeminfo

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: 

netstat

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

For example:

netstat -a 

will display all the active connections.

Conclusion: 

So this is the list of 31 awesome cmd commands tricks which you can implement. Keep visiting the article as I will add some more cmd commands. 

 If you know any other best cmd tricks then please comment down below.

Thank You!

Saish K

Author: Saish K

Hi there! my name is Saish. I hope you find this blog useful.

Leave a Reply

Your email address will not be published. Required fields are marked *

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