Contents for Ezine 77 Scriptomatic v 2.0
Scriptomatic is a delightful program, which actually creates WMI scripts for you. It displays information on all the Windows objects in the CIM library. For each object, it adds the appropriate properties to the VBScript code. The only difficulty with Scriptomatic is knowing which object to choose, and which properties of that object to cut from the final script.
About a year ago I featured Scriptomatic, but this latest version 2.0 has a ‘killer’ improvement in that you can output to html. With the earlier version, you had zillions of WScript.echo commands and as a result you had to press the OK button about 27 times before you got to the property of interest. Therefore, if you get Scriptomatic, make sure that you download version 2. Incidentally, OnScript produce a nifty piece of code that combines Scriptomatic v 2.0 with their wonderful VBScript editor. What you want is OnScript’s Scriptomatic 2.0 WMI Utility. Getting started with Scriptomatic v 2.0
Guy Recommends: The Free IP Address Tracker (IPAT)
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
Really, you need little or no instruction with Scriptomatic, indeed right from the first click, Scriptomatic makes you a ‘Professor of WMI’. In fact one of my Litmus Tests is that any new program should just work intuitively without a 350 page instruction manual. To digress, just because Guy is ‘in computing’, every week I am sent 2 or 3 programs to try. If these trial programs don’t just work instantly, then I dismiss them. You could call this arrogance, but I call it protecting my readers and preserving my sanity. The main problem is what I call developeritus, developers get their programs working perfectly on their machines, but they forget that their potential customers may have very different computer environments.
Let us suppose there is a problem with a printer. Most likely the solution is to add paper or toner; however, you may want to run a WMI script just in case there is a configuration setting that would help prevent the problem re-occurring. As with most WMI scripts, the key is identifying which are the best Win32_Classes to query. In the case of the printer there are eight Win32 objects to choose from. Consequently, it’s a case of if at first you don’t succeed try a different class of object.
Instructions for Launching Scriptomatic.
- Download Scriptomatic v 2.0 here.
- When it launches note the WMI Namespace, but leave it at Root\Cimv2, (at least for your first few tries).
- Suggested WMI Classes: Printer or PrinterConfiguration.
- My favourite Output Format, at least for testing is HTML. Once you have made your selection, click Run, which is up at the top under the WMI Namespace box.
- WMI Source Button = Computer to run script on.
Note, this is a parallel example and not a direct copy of what you see with Scriptomatic. In my opinion, the best output with Scriptomatic v 2.0 is to an html file. However, I did not want to disappoint you by sending an Ezine without a VBScript.
The only pre-requisite is that you have a printer attached to the machine where you run the script. Be aware, there may be a delay while the script checks all possible printer ports.
‘ Purpose VBScript to interrogate Printer properties through WMI
‘ Author Guy Thomas https://computerperformance.co.uk/
‘ Ezine 77 Version 1.7 – June 2005
Dim objWMIService, objItem, colItems, strComputer
‘ On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_Printer")
For Each objItem In colItems
WScript.Echo "ServerName: " & objItem.ServerName & VbCr & _
"============================================" & VbCr & _
"Attributes: " & objItem.Attributes & VbCr & _
"Availability: " & objItem.Availability & VbCr & _
"Description: " & objItem.Description & VbCr & _
"DeviceID: " & objItem.DeviceID & VbCr & _
"Direct: " & objItem.Direct & VbCr & _
"DriverName: " & objItem.DriverName & VbCr & _
"Hidden: " & objItem.Hidden & VbCr & _
"HorizontalResolution: " & objItem.HorizontalResolution & VbCr & _
"VerticalResolution: " & objItem.VerticalResolution & VbCr & _
"PortName: " & objItem.PortName & VbCr & _
"PrinterState: " & objItem.PrinterState & VbCr & _
"PrinterStatus: " & objItem.PrinterStatus & VbCr & _
"PrintJobDataType: " & objItem.PrintJobDataType & VbCr & _
"PrintProcessor: " & objItem.PrintProcessor & VbCr & _
"Priority: " & objItem.Priority & VbCr & _
"Published: " & objItem.Published & VbCr & _
"Queued: " & objItem.Queued & VbCr & _
"SeparatorFile: " & objItem.SeparatorFile & VbCr & _
"Shared: " & objItem.Shared & VbCr & _
"ShareName: " & objItem.ShareName & VbCr & _
"SpoolEnabled: " & objItem.SpoolEnabled & VbCr & _
"Status: " & objItem.Status & VbCr & _
"StatusInfo: " & objItem.StatusInfo & VbCr & _
"WorkOffline: " & objItem.WorkOffline & VbCr & _
‘ End of Sample Printer VBScript
Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft’s operating systems. Fortunately, SolarWinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your scripts.
Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory or Exchange Server. Give this WMI monitor a try – it’s free.
Most of this week’s tips are optional ways of changing or improving the Scriptomatic Output. If you stick with Scriptomatic’s own interface then you cannot go wrong, however, if you try and amend the information into your own VBScript you may experience frustration.
1) When you create a script, some of the fields, which worked in Scriptomatic no longer display, worse they halt the script. My advice is to prune the script down to basic properties, for example: "Description: " & objItem.Description & VbCr & _ and then gradually add in more and more properties.
2) In terms of VBScript tactics, we all copy and paste other people’s code, the secret is knowing which parts to amend, which to delete, and where to add extra code of your own. So, talking of simplifying, I strip out commands such as: "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly. I also remove the array code.
3) Last week (and online) I explained how to add (& VbCr & _) and remove extra WSCript.Echo. The technique revolves around the Word for Windows feature, Find and Replace.
Tired of writing scripts? The User Management Resource Administrator solution by Tools4ever offers an alternative to time-consuming manual processes.
It features 100% auto provisioning, Helpdesk Delegation, Connectors to more than 130 systems/applications, Workflow Management, Self Service and many other benefits. Click on the link for more information onUMRA.
Challenges and ideas for other Scriptomatic V 2.0 tests.
Note Array, which allows you to add several computer to your test.
Suggestions for other Classes research: ComputerSystem, Desktop, DiskDrive, Network Adapter, Process and also Processor.
Summary of Scriptomatic v 2.0
We here a lot about the cliche ‘steep learning curve’, well Scriptomatic v2.0 gives you the opposite, a gentle introduction to WMI Scripting.