Print

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

Transforming a command line script to a Windows application

We start with a simple little script as shown below:

simple sample script

It just prompts for a computer name on the command line, uses that information for WMI query and outputs the result to the console. Your existing command line scripts may just use a parameter instead of a prompt but that makes no difference for the purpose of this article.

It follows, like most scripts, a basic Input-Processing-Output pattern. If you have previously used VBScript you may feel tempted to design your user interface in the same manner: Use a message box to prompt for the computer name, process the query and then somehow display the output. This would look something like this:

sample message box for user input

Then run the query and show the output:

sample output display

This follows the same I-P-O pattern and it does the job, but it’s not ideal.  For one, you have two forms or windows to maintain and change if so required and, secondly and most importantly, you have to restart the application for each computer you want to query. One of the most important questions you have to ask yourself when designing user interfaces is: “How will others use this?” If you only were to query ONE computer you could omit the whole entering a computer name business altogether. So the assumption is that a user will want to query more than one computer, maybe even more than one computer at the same time.

So let’s start with a design that allows a user to query one computer at a time:

sample multi-user message and out box for user input

Now we can enter one computer after another, press enter or click the button and see the results, lather, rinse, repeat.

Here are some things that you should note about this form:

The PFF file for this form is available as QueryDriveSpace.zip here.

If you have questions about our products, please post in our support forum.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.