CMD Tricks
CMD Tricks
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.
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.
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
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.
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.
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.
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.
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
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.
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.
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”.
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:
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.