Systems Administrators seem to get tasked with all kinds of random everyday help items to make the average office employee more productive. This usually means helping them perform tasks that they could easily handle, shortcut creation and general file move/copy operations come to mind. Things like this might be pulled into a batch file to make the chore less taxing for the helpdesk or sysadmin which also makes the shortcut reusable. Microsoft has created a lightweight scripting language based on Visual Basic that works even better than batch files in some cases.
You probably don't have a Visual Basic or Visual Studio license lying around to use for scripting. That's where this article might be of some help. Koan Software has developed a freeware utility for creating and working with VBScript called VBSEditor.
Koan Software is based in
The application is very lightweight and has no installer, just unzip, launch the executable, and you are ready to script. Figure A below is a bit deceiving, when VBSEditor starts for the first time it might need to be stretched out so it can be used.
|The initial screen is small, so stretch it prior to use.|
All stretched out and ready to work!
When stretched out VBSEditor looks a bit like Notepad, but has a programming feel to it, including robust buttons and line counter to eliminate the need to count lines beginning at the top of the document one at a time. Another feature of VBSEditor is the Go To Line option. As expected when working on a script the editor will allow you to jump from line 3 to line 103. Go To Line is shown in Figure B. To use go to, simply click the icon highlighted in Figure B. This allows you to see the go to box and enter the line number you wish to jump to.
|Jumping around your script with Go To Line|
Creating a sample script
Now that we have seen how to get this great free scripting tool and some of the features it offers above and beyond Notepad, I will create a script. The script I will use in this example is included to show the usefulness of the editor not the functionality of the script. Translation: it doesn't do much of anything.
You've probably seen many variations on the Hello World example, but for simplicity sake I will use that one here with a couple modifications. Remember the editor is the focus, not the script.
|Look at the color-coded syntax.|
As you see in the above example the syntax of the script is highlighted just as if you had been using Visual Studio. If the usual Visual Basic highlighting is not something you are particularly fond of, clicking the options button on the tool bar will produce the script editor options dialog shown in Figure D. From here you can also control font size and indentation widths.
|Presto Chango! Different options at your fingertips|
Another wonderful thing about the free application, when you use a function defined in visual basic, inputbox() in the above graphic, the Smart Help appears to assist you in completing the argument list, again just like Visual Studio. The Smart Help is shown below in Figure E.
|Feels like Visual Studio minus the price tag|
When you enter the function name and open the parentheses to begin supplying arguments the help will appear. Separate each argument with a comma and finish the arguments list with the closing parenthesis, just like Visual Basic.
In the example script I set out to ask a user for their name and greet them with a message box. Figure F shown below appears when the script is launched and Figure G shows the greeting message box when you click OK.
|May I have your name please?|
|Hello, I am the example script.|
A great place to start
VBSEditor is a great tool for small scripting, perhaps the things that a helpdesk technician or systems administrator might create to simplify their own tasks or that of a user in their environment. Some knowledge of Visual Basic is helpful, but a tutorial or two from the Internet will point you in the right direction if you haven't any experience. It is also a great tool to introduce you to the Visual Basic Scripting language and its syntax without spending a mint on the more robust tools. However if you are going to write applications, by all means the Microsoft tools are the way to go. If scripting is your game, the VBSEditor is the tool to use.
In my next article I will provide a more robust and useful example script to get you moving down the Windows scripting path.
Derek Schauland has been tinkering with Windows systems since 1997. He has supported Windows NT 4, worked phone support for an ISP, and is currently the IT Manager for a manufacturing company in Wisconsin.