A Compilation of Command Prompt Tips, Tricks & Cool Things You Can Do

F7 makes it crash in Windows 10. If one press F7 too see the command list popup and then select one entry with enter, it crashes. It seems that was an old feature that is not fully supported now haha.
 
What I was looking for is how to select a page of email titles so you can delete them with one stroke instead of each individually? Otherwise, great info, Thanks.
 
Great article, but I would urge GREAT caution before adding the TELNET service to your system - it is VERY vulnerable to attack, and there are malicious sites port scanning your router frequently, to look for port 23 being open!!
 
To run multiple commands on a single command line, use a single ampersand. The double ampersand "&&" is a conditional - it says run the second command only if the first command completes successfully. A single ampersand says run the second command no matter what happens to the first.

And to make it more interesting, a double vertical bar means run the next command only if the first command does NOT complete successfully.

This means you can create an if/then/else all in one line:

DIR SomeDirectory && ECHO It Exists || MD SomeDirectory.

Which is "Display SomeDirectory. If it exists then say so, if it doesn't then create it." A simplistic example but it gets the idea across.
 

VBKing

Posts: 75   +36
Excellent article! My only suggestion ... put a .pdf file with all of this that can be easily downloaded .....

TIP to everyone: You can create your own PDF when necessary by right clicking on a web page and selecting PRINT as long as you have a PDF Printer device installed. Many programs will allow you to install them (PDF Editors / Viewers, Quicken, etc.) or do a google search to find one.

I have saved this article into a PDF file that you can download (if I did it right).
https://drive.google.com/file/d/14JTscikvgc-TMMZXy_pjWiVOYMXCAWCB/view?usp=sharing

Also, as another tip, I had to use uBlock (my Ad Blocker) to block some elements on this article's webpage first (ads making the PDF longer, banners that kept showing on every page and covering the 1st few lines of each page, links to other stories that aren't needed in the PDF, etc.) to get the PDF to come out nice and concise. Then I unblocked the items so as to put the TechSpot webpages back to normal.
 

complexxL9

Posts: 68   +14
Did not bother to read, I would say everything could be done easier via powershell, cmd should be killed of why people keep resurrecting this memento of ancient times.
 

arrowflash

Posts: 460   +498
TIP to everyone: You can create your own PDF when necessary by right clicking on a web page and selecting PRINT as long as you have a PDF Printer device installed. Many programs will allow you to install them (PDF Editors / Viewers, Quicken, etc.) or do a google search to find one.

I have saved this article into a PDF file that you can download (if I did it right).
https://drive.google.com/file/d/14JTscikvgc-TMMZXy_pjWiVOYMXCAWCB/view?usp=sharing

Also, as another tip, I had to use uBlock (my Ad Blocker) to block some elements on this article's webpage first (ads making the PDF longer, banners that kept showing on every page and covering the 1st few lines of each page, links to other stories that aren't needed in the PDF, etc.) to get the PDF to come out nice and concise. Then I unblocked the items so as to put the TechSpot webpages back to normal.

Great tips, instead of uBlock you can also use right click -> inspect element to remove page elements and make it more print friendly before converting to PDF. Or, there are also extensions that make this process more practical - I use "Page Eraser" on Chrome/Chromium-based browsers, and "Remove HTML Elements" on Firefox. I archive pages to pdf using these methods all the time.

Fantastic article... for those who are going to post, "I knew about all of these before" - go troll somewhere else :)

While I did know about a bunch - there were many I had no idea even existed... like the list of "F" key functions.... and the personal hotspot commands.

Well, some of us DO know most of them, but you always learn something new :)

I had never heard about driverquery, and had heard of but completely forgotten about tasklist. Very useful commands. And of course, the Telnet servers are fun.

Great article, but I would urge GREAT caution before adding the TELNET service to your system - it is VERY vulnerable to attack, and there are malicious sites port scanning your router frequently, to look for port 23 being open!!

You don't need the Telnet service, only the Telnet client, and they're enabled separately.

Did not bother to read, I would say everything could be done easier via powershell, cmd should be killed of why people keep resurrecting this memento of ancient times.

Powershell is awful. I do use it often because I have to, but I never liked it. It is slow, clunky and for more advanced stuff you usually have to type 2, 3 or even 4 times as much to achieve the same results from the command prompt. Long live the Command Prompt!
 

Mugsy

Posts: 734   +172
A couple of useful commands I recently learned about (and I'm an old pro):

"start /b" will execute the command immediately following this one (on the same line) without waiting for it to complete/close first. The "/b" switch does so without opening a new window.

So say, for example, you want to execute a program and then send that program a command via the Command Window:

start /b someapp.exe
MySendCmdApp.exe -abcde123

"someapp.exe" would start and the command on the next line would execute without waiting for "someapp.exe" to finish/close first.

Another helpful command to go with this:

timeout /t #

...where "#" is the number of seconds you want to pause before continuing.

This is helpful if you "start" a program, but need the CLI to wait until it's loaded before sending the next command.

start /b "someapp.exe"
timeout /t 20
ipconfig /flushdns
 

arrowflash

Posts: 460   +498
timeout /t #

...where "#" is the number of seconds you want to pause before continuing.

This is helpful if you "start" a program, but need the CLI to wait until it's loaded before sending the next command.

start /b "someapp.exe"
timeout /t 20
ipconfig /flushdns

Good tip. I use timeout /t ## a lot in my batch files. Often when you create a .bat that runs multiple commands / programs without some short pause between them (especially when some command/program depends on a previously finished task/command), you might run into bugs or glitches.
 

PEnnn

Posts: 635   +617
Great article, lots of DOS stuff there too...;)

For those who want this in a PDF:

Highlight whatever you want to print (use the down / up arrow keys to scroll while selecting) then tight click and print (to PDF).
 

Plutoisaplanet

Posts: 520   +772
Great article, but I would urge GREAT caution before adding the TELNET service to your system - it is VERY vulnerable to attack, and there are malicious sites port scanning your router frequently, to look for port 23 being open!!
Client software doesn't listen on designated ports to be able to run; server software has that responsibility. Server software and client software always comes separately.
You don't need the Telnet service, only the Telnet client, and they're enabled separately.
Ikr, a lot of people talk about software without understanding it.
Powershell is awful. I do use it often because I have to, but I never liked it. It is slow, clunky and for more advanced stuff you usually have to type 2, 3 or even 4 times as much to achieve the same results from the command prompt. Long live the Command Prompt!
Here I’d disagree with you. PowerShell is a full-blown programming language that does way more advanced things than you can do via the command prompt... Also a majority of commands from the command prompt is compatible with PowerShell. The original commands are verbose which is helpful with writing more readable code but you don’t have to use those (comparison here). Even the language syntax has shortcuts for things like iterations and loops (ie. (ls)[0..4].Name gets the first 5 alphabetic filenames of the current directory).

The Windows Terminal for Windows 10 is amazing though, they should make powershell.exe a shortcut for cmd.exe /c powershell.
 
Last edited: