Page 1 of 1
Get cmd result DIRECTLY!
Posted: 10 Sep 2013 18:29
by binocular222
Good news for all: We can run cmd command and receive the result immediately in a variable without piping through a text file.
Recently, SKAN, a founder of Autohotkey made a script to receive cmd result directly
http://www.autohotkey.com/board/topic/9 ... douttovar/.
Base on that, I made this exe file:
- Download the .exe
- Run this sample script:
Code: Select all
run """E:\7Utilities\XYplorer\Data\Scripts\StdOutPlain.exe"" ""ipconfig /all"" ";
msg get("CopiedData", 3);
SKAN also made another version, which allow receiving result in real time (i.e: we can have a tooltip showing "ping
http://www.xyplorer.com" every 1 second). Anyone interest in this realtime version can visit the above link
P.S: With XYplorer's runret command, this script is no longer needed
Re: Get cmd result DIRECTLY!
Posted: 12 Sep 2013 16:39
by klownboy
Hi binocular222,
As a fellow combination XYplorer and AHK user, that script and AHK exe look very promising, but what are the advantages of using it, at least for the example you gave, as oppose to simply using XYplorer by itself? Is it the fact that it eliminates the need have to call out "cmd" via XYplorer?
Code: Select all
run 'cmd /c "C:\Windows\System32\ipconfig.exe /all" > d:\downloads\ipinfo.txt' ,,2,0; open "d:\downloads\ipinfo.txt"; //change folder to suit
Thanks,
Ken
Re: Get cmd result DIRECTLY!
Posted: 12 Sep 2013 17:42
by binocular222
The advantage is you don't have to write file to disk, this means:
- No trouble with read-only disks; no worry for "you don't have permission to access this disk location..."
- Other programs may read/write too much on your hard disk at the same time, causing delay in disk writing
- writing to disk is a sloppy work-around, not the way programmers want
Re: Get cmd result DIRECTLY!
Posted: 13 Sep 2013 01:55
by klownboy
Ah yes. Though it this case the writing to disk is relatively minor and quick, it's always better not to if you have a choice. Thanks.
Re: Get cmd result DIRECTLY!
Posted: 15 Sep 2013 14:34
by klownboy
You could avoid writing and reading a text file by using the good old "|" pipe command - I'm having flash backs - going back to my DOS batch file days. I also noticed it is discussed in this thread
http://www.xyplorer.com/xyfc/viewtopic. ... lip#p85097Code: Select all
run "cmd /C ""C:\Windows\System32\ipconfig.exe /all"" | clip",,2,0; text "<clipboard>", 700, 900, "IP Config";
Another example: you can use this technique when gathering meta data for a photo using Image Magick (file selected in list). Unlike similar examples in other posts, it avoids the disk writes and reads when gathering Image Magick data and at the same time, it's a bit faster.
Code: Select all
run "cmd /C """"D:\Graphics\ImageMagick\identify.exe"" -verbose ""<curitem>"" | clip""",,2,0; text "<clipboard>", 700, 900, "Image Magick Info";
You could use this short script in a CTB menu [change the folder location of Image Magick to suit].
Re: Get cmd result DIRECTLY!
Posted: 16 Sep 2013 05:46
by binocular222
Clipboard is modified that way. That's not good at certain times
Re: Get cmd result DIRECTLY!
Posted: 16 Sep 2013 15:43
by klownboy
Hi binocular222, I wasn't in any way trying to knock the use of "StdOutPlain.exe". I think it will be a very handy utility and you know I'm a great fan of AHK as well. I was only coming up with alternatives for those who want to use a method which doesn't rely on a secondary exec or script. It was probably more as a learning experience for me. If you use a clipboard manager, writing to the clipboard really isn't much of an issue. Thanks again.