New
#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.)
- How to send text output from any command directly to clipboard
- Scroll Command Prompt window with arrow keys
- Copy & Paste in Command Prompt window
- Change the Command Prompt font
- Find your motherboard specifications
- List all installed updates, view them as a table in browser
- List all services, view them as a table in a browser
- List all installed hardware drivers
- Browse and use commands in buffer with F keys
- 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:
You will now see the word Scroll in titlebar and can scroll the window using up and down arrows:
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:
A block cursor appears at top left corner (1) and the titlebar tells you are in Mark mode (2):
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:
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:
Select Fonts tab, choose you font and text size:
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:
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:
- 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:
- User can now enter his redirection target |CLIP and execute the command:
- 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:
- F9 lets user then enter the number of command he wants to paste:
- 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 :).
TipDid 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.