Pinterest Stumbleupon Whatsapp
Ads by Google

Linux geeks are proud of their command line prowess and generally have some tricks up their sleeves. While the Windows command line is not considered as powerful as a Linux’s, here are some Windows command line tips and tricks not everyone might know about.

Drag and drop files for a full path

Tired of typing the long pathnames for files/folders buried deep inside a folder tree? Just drag and drop the file onto the command prompt window and you will get the full path and filename reveal to you.


Copy and paste from/to the command line

Click on the icon in the title bar and choose Edit > Mark. Now, drag over the area you want to copy, hit Enter and the text is copied to the clipboard. Similarly, you can click on the icon in the title bar and choose Paste to paste the text you already have on the clipboard. You can also do this by right-clicking inside the command prompt window

Ads by Google

Hit F7 for command line history

Hit F7 and you will get a complete list of commands that you executed. Use the arrow keys to highlight the command you want to run again or just hit the number key corresponding to the command that you want to execute.

History keys

Use F1 to paste the previous command one character at a time, F2 (followed by a number) to paste the previous command up to the said number and F3 to paste the previous command.

Run multiple commands

You can run multiple command by separating them with &&. Note that this doesn’t run the commands simultaneously. Instead, the command towards the left is run first and if it completes successfully then the second command will run. If the first command fails, then the second command will not run

Go fullscreen

Hit Alt+Enter and now you have the entire screen to enter your commands and view the output. Sadly,. this doesn’t work as expected in Vista and you might have to do some additional tinkering.

Change window size

So you thought you knew the previous one? How would you change the size of the window? Use the mode command. Use mode <no of characters wide>, <no of lines high> to change the size of the window. For example, mode 100, 50 will make the window 100 characters wide and 50 lines high

Get help

Linux users turn to the man command when in doubt, while Windows users don’t have complete manuals to refer. All is not lost. You can get some help for most commands by using command /? or command –help. You can also use the help command to see a list of available commands (although the list is far from extensive).

Filter command output

If you are only interested in part of command output and don’t want to spend time scanning the entire output, you can pass the output over to the find command. eg use tasklist | find “firefox” to only list the entry for Firefox if it is running.

Sleep or pause for some time

If you have ever written a batch file and wanted to wait for a period of time before you start executing the next command, you might have been amazed to find the “sleep” command missing. You can however hack yourself a sleep command using ping! Use ping -n 5 127.0.0.1 > NUL 2>&1 to wait for 5 seconds. Be warned that the timing would not be exact so don’t just bet your life on it.

Think you know some more tricks? Have a command line tip to share? Sound off in the comments and let us know!

  1. Sam
    July 4, 2016 at 12:25 am

    Copying and pasting can also be done in simpler fashion, without inoking the command window menu:
    For Copying, simply highlight the text by holding the left key (note this highlighting can be even a rectangular region of the text, if it makes any sense), and then hit Enter.

    For Pasting, simply click the right key.

  2. Noning
    May 13, 2016 at 3:26 am

    My trouble shooting will be make a lot faster and easier <3
    It's a Big Help for me :D
    Many2 Thank You, very2 Much :D

    I'll be back and Join The Group <3

  3. Ponni Priyadharshni
    August 25, 2015 at 6:55 pm

    Found it very useful! Thanks.

  4. satyendra
    November 29, 2009 at 12:13 am

    Thats really a nice info ..now i will be able to use cmd with full potential..

  5. Jim
    October 16, 2009 at 9:09 am

    Correction on running multiple commands - if you use &&, the command after the && only runs if the command before completes without error, which is what you often want. If you want the second command to run no matter what happens with the first command, use a single &.

    OK, here's where it gets real fun - you can use || to run the second command only if the first command causes an error.

    Then it gets even more fun - you can chain these together!

    A simple example:

    DIR xyzzy && Echo Found it! || Echo It's not there.

    This will run the command
    DIR xyzzy
    If xyzzy exists, then "Found it!" will be displayed
    If xyzzy doesn't exist, then "It's not there." will be displayed.

  6. Phùng Văn Huy
    September 23, 2009 at 9:13 pm

    You can
    Change title console window: title My Console Window
    Change color text/background of console window: color 0f
    Get username like whoami in Linux: echo %username%

  7. CGA
    June 11, 2009 at 2:31 am

    If you want a "real" sleep command you can download the Windows 2003 Resource Kit as per this article:
    http://malektips.com/xp_dos_0002.html

  8. hubdog
    June 10, 2009 at 11:38 am

    It's also useful to enable QuickEdit Mode to be able to highlight and paste with the mouse without having to right-click and select paste.

    Set it up by clicking the little "c:\_" icon in the upper left of the command window, and choose "defaults". On the "Options" tab check "QuickEdit Mode" and click "OK". Click the icon again, select "Properties" and check "QuickEdit Mode" and click "OK". After hitting ok this time you will get a dialog box, select "Save properities for future windows with same title." and hit ok.

    Now you will be able to use the left mouse button to highlight text, and the right mouse button to copy it. Enjoy.

    • Varun Kashyap
      June 11, 2009 at 9:51 am

      May be right click is easier ^_^

    • Martin
      June 12, 2009 at 3:21 am

      Hubdog - I always wanted an easier way to cut and paste! Thanks

  9. andy
    June 9, 2009 at 4:14 pm

    RE: FILTER COMMAND OUTPUT ........ The find command does not work but findstr does....................... o.O

  10. Gennice
    June 9, 2009 at 10:34 am

    Excellent and easy to learn explanation. Thanks for the tips!

  11. antoniobrandao
    June 9, 2009 at 8:55 am

    I know a cool command

    use "dir > filename.txt" to print the contents of the actual folder into a text file. Good to make lists of folder's contents.. the "filename.txt" doesn't have to end in ".txt" but it's convenient to open later

    use "dir > filename.txt /s" to include all subfolders

  12. Martin
    June 9, 2009 at 8:31 am

    Couple this with the "Open Command Window Here" powertoy in explorer to go straight to the directory you need. md xxxx is faster than New > Folder > type in the name > Enter, unless you want spaces.

    Did not know about the tab key.

    • Varun Kashyap
      June 11, 2009 at 9:50 am

      Yes, indeed you can use the Tab key to complete directories and filenames. Should have stuck it in somewhere!

  13. Manu
    June 8, 2009 at 4:55 am

    Very useful

  14. Girish
    June 8, 2009 at 4:24 am

    it is explained very simply.. WOW .

  15. Wor Tony
    June 7, 2009 at 5:11 pm

    Use the tab key when using cd command. It'll cycle through the available directories. You can provide a starting point such as the initial letter to narrow down the list. The tab key will also allow you to select a filename in the sameway

  16. Dan
    June 7, 2009 at 3:12 pm

    In place of find, check out findstr. It has much more robust filtering capabilities including regular expressions.

    technet.microsoft.com/en-us/library/bb490907.aspx

    • Aibek
      June 7, 2009 at 11:39 pm

      thanks for sharing

  17. Liam
    June 6, 2009 at 8:59 pm

    You can simulate a full screen in CMD with vista and windows 7.
    1. Open a cmd window
    2. Right click on the top of the window and select properties
    3. select the layout tab and change the buffer size to something close to your monitor resolution and uncheck the box "Let system position window"

Leave a Reply

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