Advanced CMD Tricks for Windows 10 / 8 / 7

aye-aye-Chris

Famous Word Swap Guru
Staff member
http://www.thewindowsclub.com/command-prompt-tricks-windows

I gleaned a couple of things from this, but the 1st 2 items are a bit confusing to me, they aren't talking about the same thing, but.... copying errors and then showing an unintended error or is it intended? ipconfig/ all ???

__________________________________________________________________________
Copying Error Commands to Clipboard Directly
Many times while performing an operation you get an error. So, you might feel the need for copying and pasting the error to the clipboard before reporting it to the concerned authorities via email or chatting. Well, with this trick you can easily store a command output to a clipboard.

To do this, simply add the command | clip at the end of the command. For e.g. Dir /d | clip.

Finding your IP address, DNS Server address and a lot more
cmd-1.jpg

___________________________________________________________________
--More-- at The Windows Cub
 

foxidrive

Retired Admin
You can run multiple command by separating them with &&

That's wrong too. A single & is for separating commands. Edit: && does the same thing, but...
Two && in a row is a conditional operator - and only runs the command after it if the previous command didn't error.

So his advice will work - but only if the command before the && worked.

Nice way to confuse people, when their batch script doesn't work. :lmao:'
Disclaimer: not all commands return an errorlevel, which is what this triggers on, making his error even harder for people to figure out...
 
Last edited:

aye-aye-Chris

Famous Word Swap Guru
Staff member
That's wrong too. ... Nice way to confuse people, when their batch script doesn't work. :lmao:'
Disclaimer: not all commands return an errorlevel, making his error even harder for people to figure out...
I'm confuzzled even more now. :agro: maybe I should have ignored the whole bloody thing!

btw, the 'clip' may well be good and very handy but it doesn't tell you where or how to recover the 'clip'. But... I have sorta figured it out. :wtf:
 

misi

Growing Little Guru
Why is this fuss?

Copying Error Commands to Clipboard Directly
Many times while performing an operation you get an error. So, you might feel the need for copying and pasting the error to the clipboard before reporting it to the concerned authorities via email or chatting. Well, with this trick you can easily store a command output to a clipboard.

To do this, simply add the command | clip at the end of the command. For e.g. Dir /d | clip.

Right click
Mark
Highlight the columns and rows with the help of your keyboard's arrows.
Hit enter
Done.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Boss_of_this_PC>
 

foxidrive

Retired Admin
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Boss_of_this_PC>

That would be Mrs misi I gather. :wink2:
how to recover the 'clip'
Clip bungs it on the clipboard - I have NFI why Microsoft thought it was a good plan not to provide the same thing to get it back off the clipboard.

This is one tool that is useful. A number of others exist, as well as some tacky ways using built in tools - not straight forward at all.
ClipText ver. 2.0 (c) 2003-2010, Horst Schaeffer
------------------------------------------------

ClipText copies clipboard text from/to a file - plain text only.

Homepage: http://www.horstmuc.de/
I love the smell of batch files in the morning! :satisfied
 

foxidrive

Retired Admin
Right click
Mark
Highlight the columns and rows with the help of your keyboard's arrows.
Hit enter
Done.
Yes, and like this:

1)
Alt-space + E + Enter
Move to where you want to mark and:
hold shift and move the arrows to highlight the section, press Enter to copy.

2)
You can left-click and drag also, and right click to copy.


Some methods of marking might need settings changed in the CMD properties - but it's been too long since I've done it and I can't recall what the defaults are. :cheers:
 

aye-aye-Chris

Famous Word Swap Guru
Staff member
I love the smell of batch files in the morning! :satisfied
How about in the afternoon? :hehe:

Remember this baby, which I have used many times, spanking you muchly for it. :satisfied
@echo off
for /L %%a in (1111,1,6666) do (
for /f "delims=7890" %%b in ("%%a") do (
if "%%a" EQU "%%b" >>file.txt echo %%a
)
)
pause

How about a very slight.... extremely slight modification... the output printing the resultant numbers in random instead of sequential?

:pray::thank-you::cheers::merci::star::thebest:
 

foxidrive

Retired Admin
the output printing the resultant numbers in random instead of sequential?
Your wish is my CMD, erm... command!

Code:
@echo off
setlocal enabledelayedexpansion
del *.bin 2>nul
for /L %%a in (1111,1,6666) do (
  for /f "delims=7890" %%b in ("%%a") do (
  if "%%a" EQU "%%b" (
  >!random!!random!!random!!random!!random!!random!!random!.bin echo(%%a
  )
  )
)
copy /b *.bin file.txt
del *.bin 2>nul
pause


And just to skin a cat in a different way, here's another version that will create 50 different files.

Code:
@echo off
setlocal enabledelayedexpansion
del file*.txt 2>nul
for /L %%z in (101,1,150) do (
echo %%z
for /L %%a in (1111,1,6666) do (
  for /f "delims=7890" %%b in ("%%a") do (
  if "%%a" EQU "%%b" (
  set "xxyyzz!random!!random!!random!!random!!random!!random!!random!=%%a"
  )
  )
)
(for /f "tokens=1,2 delims==" %%m in ('set xxyyzz') do echo(%%n&set "%%m=")>file%%z.txt
)
pause


Remember this baby, which I have used many times, spanking you muchly for it. :satisfied

I had forgotten the code, but not the task. :happy
 

foxidrive

Retired Admin
And because I can't leave anything alone - this is the same code as the second version above - merely reformatted. It may look a bit simpler. :?

Code:
@echo off
setlocal enabledelayedexpansion
del file*.txt 2>nul
for /L %%z in (101,1,150) do (echo %%z
for /L %%a in (1111,1,6666) do (
  for /f "delims=7890" %%b in ("%%a") do if "%%a" EQU "%%b" (
  set "xxyyzz!random!!random!!random!!random!!random!!random!!random!=%%a"
  ))
(for /f "tokens=1,2 delims==" %%m in ('set xxyyzz') do echo(%%n&set "%%m=")>file%%z.txt
)
pause
 

aye-aye-Chris

Famous Word Swap Guru
Staff member
I'm just looking at the last one, thank you for this. See pic to understand why. :satisfied

I'm assuming there is non-repetition in that somehow? i.e. the same number won't appear twice in each individual set? O^O

upload_2015-12-31_19-58-26.png
Top to bottom:
Ford EL Clock & Volt Meter
Radio from Rob
Radio 1 from Peter
Radio 2 from Peter
Home made P/S - Variable ~2V to ~14V ~1A

The radio's are all for me, 2 have clock display, the 3rd doesn't.

I enjoy doing these, with your help :satisfied
 

foxidrive

Retired Admin
Your stack of radios is impressive Chris. One for the man cave, one to hide inside the kitchen cabinet with not a wire to be seen. :happy Mossie wil be impressed.
Easily checked I think.
Yeah, it's the same data.

A programmatic way to compare the data is to sort an old file, and a new file, and then use the
fc /b file1.txt file2.txt
command which will show FC: no differences encountered if it's all good.

Happy New Years to you'se all in the snake territory, and all the others who waded through this thread.
 

aye-aye-Chris

Famous Word Swap Guru
Staff member
Thanks again matey, all the berry vest down your way too. :satisfied

I'm using the first out put from the last version. 1 random set was all I needed which is much better than me pulling randoms out of the ordered list which I was weighted towards the central area. 1 set used on each radio (same numbers) each hour, and awaaaaaaaaay we go.

I have 2 others, 1 in the car (sans clock) and 1 in the workshop/shed (with clock) pulled from the car as it has a bad connection in it somewhere. A technical hit is sometimes needed to make it behave. :satisfied
 

aye-aye-Chris

Famous Word Swap Guru
Staff member
View attachment 1300
Top to bottom:
Ford EL Clock & Volt Meter
Radio from Rob
Radio 1 from Peter
Radio 2 from Peter
Home made P/S - Variable ~2V to ~14V ~1A

The radio's are all for me, 2 have clock display, the 3rd doesn't.

I enjoy doing these, with your help :satisfied
Radio from Rob <-- Got him. 3132 - 1 down, 2 to go. 1/4 way down the 3rd column of the 18 columns printed from the 1st random set created.

Pity is, it's the one without a clock. But... never mind, I'll crack the others soon enough. Now I can swap with the buggy one in the shed and attempt repair on it at my leisure. :satisfied
 
Back
Top