0% found this document useful (0 votes)
237 views

CMD Tricks

The document provides 12 tricks for using the command prompt in Windows, including: 1. Opening the command prompt in a specific folder by right-clicking and selecting "Run command window here". 2. Enabling "QuickEdit mode" to allow copying and pasting text using keyboard shortcuts. 3. Running the command prompt as administrator by pressing Ctrl+Shift+Enter. 4. Viewing command history by pressing F7 or using the "doskey /history" command. 5. Copying command output directly to the clipboard by adding " | clip" to the end of a command.

Uploaded by

Ali Mohammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
237 views

CMD Tricks

The document provides 12 tricks for using the command prompt in Windows, including: 1. Opening the command prompt in a specific folder by right-clicking and selecting "Run command window here". 2. Enabling "QuickEdit mode" to allow copying and pasting text using keyboard shortcuts. 3. Running the command prompt as administrator by pressing Ctrl+Shift+Enter. 4. Viewing command history by pressing F7 or using the "doskey /history" command. 5. Copying command output directly to the clipboard by adding " | clip" to the end of a command.

Uploaded by

Ali Mohammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

CMD Tricks

1. Open Command Prompt in a Folder


When you open the command prompt, it opens up in either User or System folder depending upon
whether you ran it as administrator or not. Now the thing is, if you want to execute a file in any
particular folder, you would have to use the cd command to navigate to the folder which can be a
problem if the directory is nested way too deep.

To ease things you can open the folder in your Windows Explorer, hold Shift key when you right-click in
the folder and select Run command window here to directly open the CMD prompt with the path to
that folder directly.

2. Enable QuickEdit for Easy Copy/Paste


One thing I miss the most in Command Prompt is the ability to easily copy and paste text using the
conventional Windows hotkeys. Normally, one would have to use the right-click context menu options
to copy and paste text, but if you enable QuickEdit, you can do them using simple shortcuts.

To enable the QuickEdit mode, right-click on the Command Prompt Title Bar and select Properties. In the
Properties Window under the Option Tab enable QuickEdit Mode. That’s all; you can now quickly select
text by dragging your mouse pointer. Pressing the enter key on the selected text will copy the text to the
clipboard, and a simple left click would be enough to paste the text.
3. Run Command Prompt as Admin
Many commands require you to run command prompt as administrator. When you search for CMD in
Start Menu, other than selecting Run as administrator from the right-click menu, you can simply press
Ctrl+Shift+Enter to open it with admin privileges. This trick will work for all the programs installed on
your system.

4. See Command History


You can see last used commands in a session using the navigation buttons, but if you would like to see a
list of all the commands, you can get it by pressing the F7 button.

Alternatively, you can use the command doskey /history to list these commands in the command
prompt itself.
5. Copy Commands Output to Clipboard Directly
Sometimes one might want to copy the output from a command to clipboard, like at times when you get
an error, and you want to paste the exact error in email or while chatting with someone.
To store a command output to a clipboard add the command | clip at the end of the command.
For e.g. Dir /p | clip

6. Drag and Drop Files to Change Path


If you are already in command prompt, and you want to copy the exact path to a folder or file to run the
file or change the present working directory, you can simply drag and drop the file or the folder on the
command prompt.
The path of the dropped file or folder will show up in quotes.

7. Run Commands Simultaneously


You can put && between two commands and execute them one after another. The command on the left
will execute first followed by the command on the right of the double ampersand.
e.g. hostname && ipconfig

8. Fix corrupted system files: sfc (System File Checker)


You can easily fix corrupted system files via the command prompt.
The System File Checker finds and fixes corrupted system files. I’ll often advise readers who have
difficult-to-diagnose issues to try it, as it’s a useful baseline action to take when your operating system is
acting weird.
For example, a reader was recently able to resolve an issue where an icon had disappeared from his
taskbar—specifically, the icon for ejecting external drives safely. He fixed it by typing the command
sfc /scannow and waiting for it to do its thing, which can take five to ten minutes depending on your
system.

9. Examine your system’s energy efficiency in detail: powercfg


You can examine in detail how your system uses power with the energy report.

One of the command prompt's least-known talents is its ability to analyze all kinds of behavior about
your PC, including the way it uses power. Though it may be most useful for laptop users trying to
conserve battery, it can also be handy for desktop users looking for system inefficiencies.
Open the command prompt and type powercfg /energy. The operating system will then analyze your
system’s power usage for 60 seconds and deliver a detailed report to your System32 folder (it will tell
you the file's location).

You can also type powercfg /batteryreport for all the details on your system’s battery, including the
battery level at certain intervals of time, along with the amount of time it took to drain recently, which is
how we measure battery life in laptops at PCWorld.com. The powercfg command can do much more,
but I use these two capabilities most often.

10.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.
Simply launch the Command Prompt, and change your working directory to the folder
where your files are.
Once you’re done, type “Cipher /E“, and hit Enter. This will encrypt all the files that were inside
the folder.
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.

11.Change the Color of the CMD Window

The Command Prompt window is rather dull, in it’s default state, and it doesn’t really look appealing, or
anything special. However, this simple command will let you change the background and foreground
colors of the cmd window.

Launch the cmd window, and type “color 02“.


Hit Enter, and you will see the Command Prompt window use a black background with green text.

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

C:\> help color


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. 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 are the same.
Example: "COLOR fc" produces light red on bright white

12.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.

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 simple typing “prompt” and hitting
Enter.

13.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.

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

14.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, 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.

You can now check that the folder is indeed hidden inside Windows Explorer and cannot be seen by
anyone.
To unhide the folder, you can use the command “Attrib -h -s -r folder_name“.

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

9. List all Installed Programs

Another cool trick on the Command Prompt involves listing out all of the 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.

15. Autocomplete and Command Cycling

While typing in a command, or a path to some file inside the Command Prompt window, you can press
Tab to make Command Prompt autocomplete the command you were typing, or the path you were
trying to get at, saving you a lot of time. Pressing the up and down arrow keys can let you cycle through
the commands you have used in the current session.

16.Save a Command to a File


If you want to save results of a command to a .txt for future reference, then it is quite easy as well. All
you need to do is add “> (destination/file name with .txt extension)” at the end of the command you are
about to execute.
For example, you can type “ipconfig > c:\Networkdetails.txt”, this command will create a .txt file in C
drive with name “Networkdetails”.

17. Cycle Through Folders


Specifying exact directories can be a bit frustrating task if you don’t have the destination copied.
However, if you just know in which drive or folder the required folder is located, then you can cycle
through all the folders to reach it. To do this, just type specified drive and start press TAB key on your
keyboard to cycle through all the folders inside it.

18.Know if someone is hacking your computer/ Trace a Hacker


Want to know if someone is hacking your computer? Command Prompt can help you find if someone
you don't know is connected to your computer stealing private data. Just execute netstat -a and the
command prompt will return a list of computers that your computer is connected to. In the results
returned, Proto column gives the type of data transmission taking place (TCP or UDP) , Local address
column gives the port with which your computer is connected to an external computer and the Foreign
Address column gives the external computer you are connected to along with the port being used for
the connection. State gives the state of the connection (whether a connection is actually established, or
waiting for transmission or is “Timed Out”).

19. Get PC Drivers List


You can open list of all the drivers installed on your PC with just a single command. Just type
“driverquery” in the Command Prompt and press Enter. After a short delay, you will see all the drivers
installed in your PC along with, Name, Type and Link date.

20. Create Undelete-able Folders


You can create undeletable folders using specific set of keywords. In the Command Prompt, type the
name of the drive where you want to create the folder (it must not have Windows installed in it). After
that, type any of these keywords “md con\” or “md lpt1\” and press Enter. So it should look something
like this “D: md con\”.
This will create a folder with the same name that could not be deleted or renamed. To delete the folder
replace “md con\” with “rd con\” or “md lpt1\” with “rd lpt1\”.

You might also like