Saturday, September 24, 2016

Windows RUN dialogue ... run command and display in notepad

The windows run dialogue :

[what the title says]
 













You can fish this up by pressing the windows key and r at the same time. Or find it in your start menu, labeled "Run...".
Obviously on "cool" windows and not "user-friendly ui" windows 8 or 10 ... as I don't use them. If your doing dev. stuff, well maybe stick to windows with a proper ui)


These are my notes on how to run a command in the windows run dialogue (windows key + r) and send (pipe) the results to notepad.
This is handy for those wanting to "ipconfig" and not have to open cmd first.
The thing to remember here is the run dialogue is not the same as command line.
So a simple > or | doesn't work straight off the bat. 
You can only use those in cmd.
If you open cmd and then call your command from there, you can pipe, write or get data.
You can call "cmd" on the windows run dialogue.


echo test message > text.txt | notepad text.txt
this doesnt work with w+r but does work on cli
...so...

cmd /k ipconfig

this opens cmd and does ipconfig

cmd /c ipconfig
this opens cmd , does ipconfig and then the console window closes immediately

...so...


cmd /c echo test message > text.txt | notepad text.txt
opens cmd , does an "echo test message" that is sent to text.txt , which is piped to notepad , after closing notepad the console will close

a step further - lets remove the text.txt file after you close notepad :)
cmd /c echo test message > text.txt | notepad text.txt & del text.txt


so here's a quick ipconfig to notepad :
cmd /c ipconfig > x | notepad x & del x


or send ipconfig to cmd and do a pause , console closes after any key is pressed (aaaaanny key (as long as its 0-9 a-z (:))))
cmd /c ipconfig & pause






No comments: