Latest

Command Prompt Tricks and Hacks

The Windows Command Prompt tool, and many of its commands might seem boring or even relatively useless at first glance, but as anyone who has ever used the Command Prompt very often can tell you, there's much to love!


1.    View a Command's Results One Page (or Line) at a Time :


Ever run a command, like the dir command, that produces so much information on the screen, One way around this is to execute the command in a special way so whatever information is generated is shown to you one page, or one line, at a time.

One of my other CMD hacks (which you'll see below) provides a different solution to this problem using something called a redirection operator.

For example, executing dir /s | more will generate the thousands of lines of results that you expect from the dir command, but the more command will pause each page of results with -- More -- at the bottom of the page, indicating that the command is not done running.


2.    Run Command Prompt as an Administrator Automatically


Many commands require that you execute them from an elevated Command Prompt in Windows - in other words, execute them from a Command Prompt that's run as an administrator.

You can always right-click on any Command Prompt shortcut and choose Run as administrator, but creating a shortcut to do the same thing can be a huge time saver if you're a frequent Command Prompt power user.

3.    Become a Command Prompt Power User With Function Keys


The fact that the function keys actually do something at the Command Prompt is maybe one of the best-kept secrets about the tool:

F1: Pastes the last executed command (character by character)
F2: Pastes the last executed command (up to the entered character)
F3: Pastes the last executed command
F4: Deletes current prompt text up to the entered character
F5: Pastes recently executed commands (does not cycle)
F6: Pastes ^Z to the prompt
F7: Displays a selectable list of previously executed commands
F8: Pastes recently executed commands (cycles)
F9: Asks for the number of the command from the F7 list to paste

4.    Get Help for Any Command


Any command can be suffixed with the /? option, usually called the help switch, to display detailed information about the command's syntax. The help switch is the coolest Command Prompt trick you've ever heard of, but it's hard to disagree that it's one of the more useful.

5.    Save a Command's Output to a File


With the use of redirection operators, specifically the > and >> operators you can save command screen output.


6.    Customize the Command Prompt Title Bar Text

Tired of that Command Prompt title bar text? No problem, just use the title command. Please note, the change won't stick, so the next time you open Command Prompt the title bar will be back to normal.

The title command is usually used to help give a custom appearance in script files and batch files.


7.    Drag and Drop For Easy Path Name Entry

Most Command Prompt commands require you, or have options, to specify full paths to files or folders, but typing out a long path can be frustrating, especially when you miss a character and have to start over.

For example, in Windows 10, the path to the Accessories group in my Start Menu is C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories. Who wants to type that all in manually?

Fortunately, there's a Command Prompt trick that makes this much easier: drag and drop Just navigate to the folder you want the path for in Windows Explorer. Once there, drag the folder or file to the Command Prompt window and let go. The full path is inserted, saving you a considerable amount of typing depending on the length and complexity of the pathname.

Please note, Unfortunately, the drag and drop feature does not work in an elevated Command Prompt.

8.    View Your Computer's Important Network Information

Everything you'd want to know about your network connection is available somewhere in the Control Panel in Windows, but it's much easier to find, and much better organized, in the results from the ipconfig command.

Open Command Prompt and execute ipconfig /all.
What displays on screen next is everything important about your network connection: your IP address, hostname, DHCP server, DNS information, and much, much more.

9.    Automatically Complete Commands With Tab Completion

Tab completion is another Command Prompt trick that can save you lots of time. To use tab completion at the Command Prompt, just enter the command and then the portion of the path that you do know, if at all. Then press the tab key over and over to cycle through all of the available possibilities.

This command Hack will definitely help you in daily life as well as for computer troubleshooting.

No comments