Thursday 26 December 2013

Command Prompt Tricks and HacksCommand Prompt Tricks, Hacks

The Windows Command Prompttool, 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! Below are several Command Prompt tricks and other Command Prompt hacks that I guarantee will get you excited about many of the mundane sounding Command Prompt commandslike telnet, tree, or robocopy... okay, robocopy sounds pretty cool. Some of these Command Prompt tricks and hacks are special features or uses of the Command Prompt itself, while others are just neat or relatively unknown things you can do with certain commands. Enjoy! 1. Use Ctrl-C to Abort a Command Just about any command can be stopped in its tracks with the abort command: Ctrl-C. If you haven't actually executed a command, you can just backspace and erase what you've typed, but if you've already executed it then you can do a Ctrl-C to stop it. Warning:Ctrl-C isn't a magic wand and it can't undo things that aren't undoable, like a partially complete format command. However, for things like the dir command that seem to go on forever or questions you're asked at the prompt that you don't know the answer to, the abort command is an excellent Command Prompt trick to know. 2. 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 that it's almost useless? You're not alone. 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. To do this, just type the command, the dir command for example, and then follow it with the pipe redirection operatorand then the more command. For example, executingdir /s | morewill 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. Just press the space bar to advance by page or press the Enter key to advance one line at a time. See Command Prompt Trick #7 below for a different solution to this problem. 3. Run Command Prompt as an Administrator Automatically Many commands require that you execute them from an elevated Command Promptin 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 chooseRun as administratorbut creating a shortcut to do the same thing can be a huge time saver if you're a frequent Command Prompt power user. To complete this Command Prompt trick, just create a Command Prompt shortcut on the desktop, enter the shortcut's properties and then select theRun as administratorbox located in theAdvancedbutton on theShortcuttab. 4. Become a Command Prompt Power User with Function Keys The fact that the function keys actually do something in 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 Command Prompt Trick #17 is full of arrow key shortcuts, a few of which are similar to these function key tricks. 5. Hack the Prompt Text Did you know that the prompt itself in the Command Prompt is completely customizable thanks to the prompt command? It is, and when I say customizable, I meanreallycustomizable. Instead ofC:\>, you can set the prompt to any text you want, have it include the time, the current drive, the Windows version number, you name it. One useful example isprompt $m$p$gwhich will show the full path of a mapped drive in the prompt, alongside the drive letter. You can always executepromptalone, without options, to return it to its sometimes boring default. 6. Get Help for Any Command Believe it or not, the help comma nddoesnotprovide help for every Command Prompt command. However, any command can be suffixed with the/?option, usually called the help switch, to display detailed information about the command's syntax and often times even some examples. I doubt that 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. Unfortunately, neither the help command nor the help switch offer much in the way of explaining how to interpret the syntax. See How To Read Command Syntaxif you need help with that.

Yash

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.

0 comments:

Post a Comment

 

Copyright @ 2013 H@cking Tricks.