Download http://groups.msn.com/windowsscript/Documents/Utilities%2FRunomatic.zip
People often ask us questions like this: How come you don’t add the ability to save output to a text file to all your scripts? It would really be cool to be able to run a script against all the computers in an Active Directory OU; how come you don’t add this capability to all of your scripts? I need a script that can run against a different set of computers each time; how come your Script Center scripts don’t automatically let you do that?
Well, aside from the fact that we are way too lazy to do all that work, we have some good reasons for not doing that. First, we don’t really know which of these capabilities any one person wants. Person A might want to run a script against an OU, Person B might want to run a script against a list of computers stored in a text file. Person C might want something else. Theoretically, of course, we could include all these capabilities in all our scripts. But that’s something we don’t want to do. Our scripts are really designed to be teaching tools, to show you how easy it is to write scripts. As teaching tools, therefore, we try to keep our scripts as lean and mean as possible; that’s the reason, for example, why you rarely find error-handling in the scripts. We want to keep your focus on the key lines, the code that actually carries out the task. If we were to add all these additional capabilities, a script that might currently be no more than 5 or 6 lines long would now be hundreds of lines long. Showing people a 300-line script and telling them, “This script allows you to map a network drive” is not exactly the optimal way convince them that scripting is a quick and easy way to manage computers.
So how do we make it easy for people to run scripts against multiple computers or to save data in multiple formats, yet at the same time keep our scripts short and to-the-point? There’s really only one answer: the Runomatic.
The Runomatic (which consists of a single file, runomatic.hta) is designed to run Script Center scripts against multiple computers (if desired) and either displaying the output in a command window, or saving it HTML, plain text, or Excel (technically, comma-separated values) format. The cool thing, of course, is that the Runomatic supplies all the code for carrying out these tasks. You don’t have to change a thing in your simple little Script Center script.
Important clarification. The scripts you run in the Runomatic don’t actually have to be from the Script Center. However, they need to follow the Script Center style. Script Center scripts are primarily WMI scripts that start off by configuring a variable (strComputer) to a computer name. This is almost always a computer named “.” Which, in WMI parlance, represents the local computer. Thus:
strComputer = “.”
Later on, the script will connect to the WMI service on the computer represented by the variable strComputer, usually like this:
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
As long as your script uses a variable named strComputer to represent the computer name, it should work just fine in the Runomatic.
To use the Runomatic, create a folder (optimally titled Runomatic) and put runomatic.hta in there. Ideally, you would also put a file named computers.txt in that folder as well. This is the default file Runomatic looks for when it starts; if it finds it, it will load the computer names into the Available Computers listbox (more on that shortly). The text file should just be a list of computer names (or IP addresses), one name/IP address per line:
atl-dc-01
atl-dc-02
192.168.1.1
192.168.1.2
atl-ws-01
atl-ws-02
The .zip file for the preview edition includes a sample computers.txt file, one that has only a single entry (.) to represent the local computer.
You might also create a folder named Scripts and put some representative scripts in there. By default, Runomatic will look for this folder and add the script names into the Available Scripts listbox. The .zip file also includes a few sample scripts you can use when setting this up.
If you do all that and then double-click runomatic.hta.