Windows Tip Sheet

It’s A GUI-ful Day

You can get lots of info with the CLI, so what you need is a CLI GUI to view it all.

As you’ve probably surmised by now, I’m a big command prompt fan. Command Line Interface (CLI) tools often get the job done much faster than navigating through a GUI. CLI tools can also generate a lot of information. Some tools can generate more information than I can view in a CLI window. What I really need is a GUI for the CLI.

I put together a simple batch file that will take the output of any CLI expression, command or tool, along with up to eight parameters and present it temporarily in Notepad. Here’s the batch file:

@echo off
::Guify.bat
::Usage command [command parameters]
REM This script captures the output of any commandline utility
REM that writes the console and sends it to Notepad
REM if no command is specified, don't do anything
REM and go to the end of the script.
if %1$==$ GoTo :EOF
REM Specify the temp file variable
set tmpFile=%temp%\~guifytmp.$$$

echo Calling %1 %2 %3 %4 %5 %6 %7 %8 %9
Call %1 %2 %3 %4 %5 %6 %7 %8 %9 > %tmpFile% && start /wait notepad
%tmpFile% && del %tmpFile%

REM Clear the temp file variable
set tmpFile=
:EOF

Put the batch file in your Windows directory or some directory in your path. To use, at a CLI prompt type:

Guify SomeCommand

For example, you might try:

Guify ipconfig /displaydns

to show the DNS entries cached locally.

The batch file redirects the command output to a temporary text file. Then it opens the text file in Notepad. Once Notepad is closed, the temp file is deleted. You can copy and paste the information in Notepad to another file or use SaveAs.

The tool works for most CLI commands but is not 100% foolproof. There are some commands and utilities that can’t be redirected. For example, something like netstat /? > test.txt will fail, which means guify.bat will also fail. But a command line guify netstat -an will work.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular