We start with a simple little script as shown below:
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:
Then run the query and show the output:
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:
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.