Trivial Tricks - Some less known Command Prompt features

Page 1 of 3 123 LastLast

  1. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #1

    Trivial Tricks - Some less known Command Prompt features


    Just for fun, here are a few Command Prompt Tips & Tricks which seem to be surprisingly unknown to great many users. Just a few ones, if you have more to add please let me know. All these tricks work on Vista or later versions of Windows in both normal and administrator Command Prompt. I will update this list of more unknown commands and features whenever you geeks let me know of your gems :).

    Contents
    (In order of which entries have been added.)
    1. How to send text output from any command directly to clipboard
    2. Scroll Command Prompt window with arrow keys
    3. Copy & Paste in Command Prompt window
    4. Change the Command Prompt font
    5. Find your motherboard specifications
    6. List all installed updates, view them as a table in browser
    7. List all services, view them as a table in a browser
    8. List all installed hardware drivers
    9. Browse and use commands in buffer with F keys
    10. List all user profiles with their respective security identifiers (SID)


    1. How to send text output from any command directly to clipboard

    Let's start with a real practical one. How many of you sometimes asks OP to show for instance the output from IPCONFIG or some other command in their posts? When the output is asked we often tell the OP to send the output to a text file, then copy and paste the content of that file here, so we instruct the OP to give the command like this:

    IPCONFIG >C:\Users\UserName\Desktop\MyIPConfig.txt

    Now the OP needs to open the MyIPConfig.txt file, select all, copy and finally paste it in his post.

    Why not simplify this? Using the Pipe character (|) we can send the output directly to clipboard, bypassing the unnecessary steps of creating a text file and selecting / copying its text. Next time, tell OP to give this command and press CTRL + V in his post, that's it:

    IPCONFIG |CLIP

    The Pipe + Clip (|clip) at the end of any command line sends the text output of that command directly to clipboard.


    2. Scroll Command Prompt window with arrow keys

    By default when pressing the up or down arrow keys, Command Prompt goes through the command buffer, commands you have previously given. If you want to scroll the Command Prompt window to see your previous commands and their output you have to use the mouse and the scrollbar.

    I like to scroll with arrow keys. To do that open the Command Prompt context menu by right clicking its titlebar and select Edit > Scroll:

    Trivial Tricks - Some less known Command Prompt features-2014-09-19_16h29_31.png

    You will now see the word Scroll in titlebar and can scroll the window using up and down arrows:

    Trivial Tricks - Some less known Command Prompt features-2014-09-19_16h31_30.png

    Exit the Scroll mode by pressing ESC.


    3. Copy & Paste in Command Prompt window

    As you certainly know, the keyboard shortcuts CTRL + C to copy and CTRL + V to paste do not work in Command Prompt window.

    To copy any text from the Command Prompt, open the context menu and select Edit > Mark:

    Trivial Tricks - Some less known Command Prompt features-2014-09-19_16h36_34.png

    A block cursor appears at top left corner (1) and the titlebar tells you are in Mark mode (2):

    Trivial Tricks - Some less known Command Prompt features-2014-09-19_16h38_25.png

    Bring the block cursor to where you want to start marking, press and hold the SHIFT key and using arrow keys go to end of the part you want to mark. Now release the SHIFT key and press Enter to copy the marked region (the text it contains) to clipboard:

    Trivial Tricks - Some less known Command Prompt features-2014-09-19_16h40_26.png

    You can now paste the marked and copied text normally anywhere you want to.


    4. Change the Command Prompt font

    Command Prompt context menu, select Properties:

    Trivial Tricks - Some less known Command Prompt features-2014-09-19_16h46_37.png

    Select Fonts tab, choose you font and text size:

    Trivial Tricks - Some less known Command Prompt features-2014-09-19_16h47_06.png


    5. Find your motherboard specifications

    This one from fellow geeg Maxie: To see the manufacturer, model and serial number of your motherboard, give the following command:

    wmic baseboard get product,Manufacturer,version,serialnumber

    Like this, input highlighted with yellow, output green:

    Trivial Tricks - Some less known Command Prompt features-2014-09-20_12h06_17.png


    6. List all installed updates, view them as a table in browser

    To create an HTML file containing a list (table) of all installed updates on your system, give this command:

    wmic qfe list brief /format:htable > "%USERPROFILE%\Desktop\Updates.html"

    This creates a file Updates.html on your desktop. The file can be opened with any browser, it lists all updates installed on your system in a table.


    7. List all services on your system, view them as a table in browser

    Next two (#7 & #8) are samples taken from the Seven Forums DM Log Collector, thanks for the tip John. To get a table of all services on your system, give the following command:

    wmic service list full /format:htable >%USERPROFILE%\Desktop\Services.html

    This creates a file Services.html on your desktop. The file can be opened with any browser, it lists all services on your system in a table.


    8. List all installed hardware drivers

    Sometimes it's handy to get an easy to get a list of all your installed drivers. Luckily it is quite easy using Command Prompt. Give this command to copy the list to clipboard, you can paste it from there to a post or a document:

    sc query type= driver state= all |clip

    If you want the list in a text file instead, replace the Pipe + CLIP switch (|clip) with path and filename:

    sc query type= driver state= all > "%USERPROFILE%\Desktop\Installed_Drivers.txt"

    This creates a text file Installed_Drivers.txt on your desktop.


    9. Browse and use commands in buffer with F keys

    These practical beauties come from fellow member A Guy:

    - F1: Pastes the last executed command (character by character)
    • Example: if the last executed command was attrib, first press of F1 pastes an a, next press t, third press another t and so on, each consecutive F1 pastes one more character

    - F2: Pastes the last executed command (up to the entered character). When F2 is pressed, a dialog opens to ask a character. When this character is given the last command is pasted to the first appearance of this character. An example:
    • User has sent the directory (folder) listing of E:\Users to his desktop to a file. User wants to repeat the command but this time copy the directory listing of E:\Users directly clipboard. He presses F2, a dialog opens to ask a character:

      Trivial Tricks - Some less known Command Prompt features-2014-09-21_12h55_02.png
    • As the beginning of the command is the same, user only wanting to change the target >PATH_AND_FILENAME to |CLIP, user enters the character > to paste the command up to this character. The command is now pasted up to given character:

      Trivial Tricks - Some less known Command Prompt features-2014-09-21_12h55_45.png
    • User can now enter his redirection target |CLIP and execute the command:

      Trivial Tricks - Some less known Command Prompt features-2014-09-21_12h56_11.png

    - F3: Pastes the last executed command (same than pressing Up arrow once)
    - F4: Deletes current prompt text up to the entered character
    - F5: Pastes recently executed commands (does not cycle, same than pressing Up arrow repeatedly)
    - F6: Pastes ^Z to the prompt
    - F7 + F9: F7 and F9 work together:
    • F7 displays a selectable list of previously executed commands:

      Trivial Tricks - Some less known Command Prompt features-2014-09-21_13h14_31.png
    • F9 lets user then enter the number of command he wants to paste:

      Trivial Tricks - Some less known Command Prompt features-2014-09-21_13h14_57.png

    - F8: Pastes recently executed commands (cycles)


    10. List all user profiles with their respective security identifiers (SID)

    This command lists all available user accounts with their respective security identifiers (SID):

    wmic useraccount get name,sid



    That's it for now, I will ad more later :).

       Tip
    Did you know that launching any program from elevated Command Prompt, the program starts with administrative privileges?

    An example: Using Notepad, if you edit any INI or other settings file which is located in C:\Windows, a protected system folder, and try to save it you get an Access Denied error message. To work around this you need to run Notepad by right clicking it and selecting Run as administrator.

    If you happen to have the elevated Command Prompt already open, you can run Notepad with admin rights simply by typing Notepad and hitting Enter. As it will now be launched from elevated Command Prompt, it inherits the admin rights and you can edit & save in protected system folder.

    This applies to any Windows application and program.


    Kari
    Last edited by Kari; 30 Sep 2014 at 17:08. Reason: This post will be edited when new entries are added.
      My Computer


  2. Posts : 20,583
    Win-7-Pro64bit 7-H-Prem-64bit
       #2

    Pretty cool Kari,
    Is it time to change your description An Angry Old Man to something else like Scary Smart
      My Computer


  3. Posts : 3,253
    Windows 10 Pro x 2/Windows 11 Home
       #3

    I learned some new tricks today kari this has the markings of a great tutorial written all over it giving Brink a "run for the money" in the tutorial dept.
      My Computer


  4. Posts : 17,545
    Windows 10 Pro x64 EN-GB
    Thread Starter
       #4

    Thanks MoneyPit. In my opinion this is really trivial, mostly for fun, that's why I posted it here in Chillout :).
      My Computer


  5. Posts : 18,415
    windows 7 home 64bit
       #5

    Nice work Kari .. I use the one below to get Motherboard Information ..


    I am certain you would know it ...



    wmic baseboard get product,Manufacturer,version,serialnumber
      My Computer


  6. Posts : 17,545
    Windows 10 Pro x64 EN-GB
    Thread Starter
       #6

    maxie said:
    Nice work Kari .. I use the one below to get Motherboard Information ..

    I am certain you would know it ...

    wmic baseboard get product,Manufacturer,version,serialnumber
    That's a good one! Added.

    WMIC is really useful, another practical use for it is to create a list (HTML table) of installed Windows Update KB-hotfixes:

    wmic qfe list brief /format:htable > "%USERPROFILE%\Desktop\Updates.html"

    This creates an HTML file Updates.html on user's desktop. List can then be viewed with any browser. Added this one, too.
      My Computer


  7. Posts : 3,253
    Windows 10 Pro x 2/Windows 11 Home
       #7

    Kari said:
    Thanks MoneyPit. In my opinion this is really trivial, mostly for fun, that's why I posted it here in Chillout :).
    This is not trivial at all kari as I see more entries have been added and with a wealth more of tricks added to make a proper tutorial this would be useful to many members and would not be lost in a couple of weeks because newer threads are posted making this gem less visible.
      My Computer


  8. Posts : 17,545
    Windows 10 Pro x64 EN-GB
    Thread Starter
       #8

    I already asked admins opinion on this, if the thread should be moved. In all honesty, as there are only the News and Chillout sections where repping is not possible and for some odd reason I wanted this to be "non-reppable", I posted it here.
      My Computer


  9. whs
    Posts : 26,210
    Vista, Windows7, Mint Mate, Zorin, Windows 8
       #9

    Learned a couple of new ones. Thanks Kari.
      My Computer


  10. Posts : 17,545
    Windows 10 Pro x64 EN-GB
    Thread Starter
       #10

    You are welcome Wolfgang. My absolute favorite is the ANY_COMMAND |CLIP, to get the command output directly to clipboard:
    • dir |clip
    • ipconfig |clip
    • attrib |clip
    • ... and so on
      My Computer


 
Page 1 of 3 123 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 20:15.
Find Us