Guy’s Scripting Ezine 34 – Scriptomatic

Contents for Guy’s Scripting Ezine 34 – Scriptomatic

This Week’s Secret

This Week’s Secret is a utility called Scriptomatic.  Here is a wonderful program from Microsoft which will extend your scripting techniques.  What Scriptomatic does is to help you analyse and dissect objects such as users, computers, or even the operating system itself.

Scriptomatic has those twin hallmarks of a great utility, it automates repetitive tasks, and teaches you more about scripting methods.  Most of all, Scriptomatic saves you having to grapple with that tricky WMI syntax  What you see there in the interface are all the VBScript commands laid out perfectly; all that remains is for you click ‘Run’.  Merely inspecting that list of options is bound to generate ideas for your own scripts. As ever, I will give you examples to get you started.

Introduction to Scriptomatic

Scriptomatic is an .HTA file which connects to the operating system and then displays information on Win32 ‘classes’ such as, UserAccount, DiskDrive or even the BIOS.  HTA files are a cross between HTML and VBScript; if you wish, you can inspect Scriptomatic.hta with Notepad or your favourite HTML editor.

Once you have obtained a free copy of Scriptomatic, just double click to execute. As the .HTA file runs, you briefly see a dialog box with ‘Loading WMI Classes’. This means that the script uses the Windows Management Interface to interrogate the operating Win32 classes. In plain English, Scriptomatic gives you a handle on objects such as; user, disk or network adapter.

When you have selected which class to investigate, you can either, click ‘Run’ and instantly see the output in a ‘Dos Box’, or else save to a .vbs file and run that script to produce a WScript message box. The good news about Scriptomatic is that it outputs just about every property that can be scripted. The bad news is that you become swamped with data. So the key is to be ruthless and delete unwanted lines or elements before you run the script.

Beware: If you run the raw .vbs scripts without editing, then you will be overwhelmed with data, so get ready with Task Manager, Processes (Tab), wscript.exe (Image Name) right-click – end process. Or else you may have to press the enter key 20,000 times. (So I exaggerate, but a run-away script can be a tiresome.)

Example 1 Getting Started: A script to enumerate all your users.

Warning: For once, I would not, repeat NOT, run the Example 1 script.  Just admire its methods, then compare with my modifications in example 2.  If you do run Example 1, then get ready with Task Manager – End Process.

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount",,48)
For Each objItem in colItems
Wscript.Echo "AccountType: " & objItem.AccountType
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Disabled: " & objItem.Disabled
Wscript.Echo "Domain: " & objItem.Domain
Wscript.Echo "FullName: " & objItem.FullName
Wscript.Echo "InstallDate: " & objItem.InstallDate
Wscript.Echo "LocalAccount: " & objItem.LocalAccount
Wscript.Echo "Lockout: " & objItem.Lockout
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PasswordChangeable: " & objItem.PasswordChangeable
Wscript.Echo "PasswordExpires: " & objItem.PasswordExpires
Wscript.Echo "PasswordRequired: " & objItem.PasswordRequired
Wscript.Echo "SID: " & objItem.SID
Wscript.Echo "SIDType: " & objItem.SIDType
Wscript.Echo "Status: " & objItem.Status

Guy Recommends: The Free IP Address Tracker (IPAT) IP Tracker

Calculating IP Address ranges is a black art, which many network managers solve by creating custom Excel spreadsheets.  IPAT cracks this problem of allocating IP addresses in networks in two ways:

For Mr Organized there is a nifty subnet calculator, you enter the network address and the subnet mask, then IPAT works out the usable addresses and their ranges. 

For Mr Lazy IPAT discovers and then displays the IP addresses of existing computers. Download the Free IP Address Tracker

Example 2 Putting Scriptomatic to work.

Here below, is the script that I do recommend you test.

Whilst Scriptomatic is fantastic, it benefits from fine tuning.  My main idea is to produce one WScript message with 17 entries in one box, rather than 17 boxes each with a one line entry.

Modifications in Example 2

& VBcr   This joins or concatenates a carriage return.  The result is a new line for each item.

_ (Underscore) this tell the script there are more statements on the next line, note the use of ampersands (&).

Tip.  What I did was a Find and Replace.  Find = WScript.Echo, Replace = & VBCr _ &.   Then I made adjustments to the end of line with carriage returns and deletes.

I love the construction: If Then… End if, here I use the ‘If Then command’ to filter just the administrator, rather than repeating the message box for each of my 500 users.
If = "Administrator" Then

‘ ScriptomaticAdmin.vbs – Enumerates the Administrator’s properties
‘ Author Guy Thomas
‘ Version 1.2 – June 20th 2004
‘ ————————————————————-‘
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount",,48)
For Each objItem in colItems
If = "Administrator" Then
WScript.Echo "AccountType: " & objItem.AccountType & VBCr _
& "Caption: " & objItem.Caption & VBCr _
& "Description: " & objItem.Description & VBCr _
& "Disabled: " & objItem.Disabled & VBCr _
& "Domain: " & objItem.Domain & VBCr _
& "FullName: " & objItem.FullName & VBCr _
& "InstallDate: " & objItem.InstallDate & VBCr _
& "LocalAccount: " & objItem.LocalAccount & VBCr _
& "Lockout: " & objItem.Lockout & VBCr _
& "Name: " & objItem.Name & VBCr _
& "PasswordChangeable: " & objItem.PasswordChangeable & VBCr _
& "PasswordExpires: " & objItem.PasswordExpires & VBCr _
& "PasswordRequired: " & objItem.PasswordRequired & VBCr _
& "SID: " & objItem.SID & VBCr _
& "SIDType: " & objItem.SIDType & VBCr _
& "Status: " & objItem.Status
End If

Learning Points

Note 1:  strComputer "." means THIS COMPUTER.

Note 2:  Here is where Scriptomatic earns its corn and connects to Windows Management Interface.
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Note 3:  the ‘col’ in colItem  means collection.

Note 4:  objItem.Domain  The word after the full stop is a property, for example .domain .fullname or .installdate.

Note 5:  Select * from Win32_UserAccount. In another script, for a different purpose, Scriptomatic could change this line to: Win32_Bios or Win32_DiskDrive.

Note 6:  An old friend ‘GetObject’ and a new method ‘ExecQuery’

Further modifications

Cut out unwanted lines.  For Example delete:
& "InstallDate: " & objItem.InstallDate & VBCr _

An obvious modification would be to change Administrator to another user.

Note: The last line has a different ending (there is no & VBCr _)

Different tactics.

I have merely scratched the surface, given you one example of a familiar object – a ‘user account’.  There are zillions of other classes that you could have selected within Scriptomatic’s drop down box.  More often than not, the raw Scriptomatic code can be improved by replacing some of the echo statements with VBCr.


Scriptomatic is a ‘must’ utility for building up your collection of VBScripts.  Learn about the objects, methods and syntax of VBScript while you explore the WMI classes. 

See more about VBScript

VBScripts  • Ezines  • WMI  • Logon Scripts  • Tool Kit

Ezine 26 SendKeys  • Ezine 34 Scriptomatic  • Ezine 47 .put  •Ezine 51 Sleep  • Ezine 52 OS

Ezine 77 Scriptomatic  • Ezine 84 AcctInfo  • Ezine 88 Progress bar  • Ezine 89 SendKeys

Ezine 97 Net Time  • Ezine 98 W32 Time  • Ezine 99 Time services  • Ezine 120 Sendkeys