I recently downloaded Microsoft's Scriptomatic tool from http://www.microsoft.com/technet/scriptcenter/tools/wmimatic.asp, and I'm running into a problem. The scripts I create with Scriptomatic fail to retrieve some properties and values when valid data exist. For example, if I use the Windows Management Instrumentation (WMI) Tester (wbemtest.exe) to query the Win32_BIOS class, the tester returns valid data for the Win32_BIOS class's BiosCharacteristics property. However, if I use Scriptomatic to query the Win32_BIOS class, BiosCharacteristics comes back empty. The line of code that Scriptomatic generates isn't displayed at all. Am I doing something wrong?
You aren't doing anything wrong. The problem you're encountering is a documented limitation with the first release of Scriptomatic. (See the fourth bullet from the bottom in the document "Write WMI Scripts Like the Pros" that accompanies the first release of Scriptomatic.) The first release of Scriptomatic doesn't support properties of type array. As you probably guessed, the Win32_BIOS class's BiosCharacteristics property is an array.
The reason you don't see an error when you run the script is that all Scriptomatic scripts enable On Error Resume Next, VBScript's error-handling mechanism. On Error Resume Next has the effect of suppressing the error that would otherwise result from trying to access an array as a scalar (i.e., single) value. You'll see the error I'm talking about if you comment or remove the On Error Resume Next line, save the script, and run the saved copy of the Win32_BIOS Scriptomatic script.
Microsoft addressed the array limitation in the second release of Scriptomatic. However, the second release is available only on the CD-ROM that accompanies the Microsoft Windows 2000 Scripting Guide (http://www
.microsoft.com/mspress/books/6417.asp). How do you tell which release you have? If you don't own the Microsoft Windows 2000 Scripting Guide, you most likely have the first release. If you're not sure, you can look at the scriptomatic.hta file's date stamp to determine which release you have. The first release of Scriptomatic, which doesn't support arrays, carries a Created date stamp of August 09, 2002. The second release, which supports arrays, carries a Created date stamp of November 06, 2002. Also keep in mind that the limitation I'm talking about applies only to the WMI Scriptomatic Tool and not ADSI Scriptomatic, which you can download from http://www.microsoft.com/technet/scriptcenter/tools/admatic.asp.
How do you address the array limitation short of buying the book? You could certainly enhance your copy of Scriptomatic by adding the code necessary to detect and handle properties of type array. I have a better solution, however. By the time you read this, Microsoft will have released Scriptomatic 2.0 (the third release, not to be confused with the second release that appeared only with the Microsoft Windows 2000 Scripting Guide). I won't spoil the fun here, but Scriptomatic 2.0 includes a bunch of new bells and whistles in addition to addressing the array limitation. Although I can't give you a URL to Scriptomatic 2.0 because of timing, you should be able to access and download it from the Microsoft TechNet Script Center portal (http://www.microsoft.com/technet/scriptcenter/default.asp).