FREE: WMI Code creator – Generate VBScript, C#, and VB.NET code that uses WMI
By Mike Taylor | No Comments | PermalinkThis is part two of a three part series of articles covering two great WMI tools, the first tool being Microsoft's free WMI Code Creator.
WMI Code Creator is a tiny (300KB) Microsoft tool available here. To demonstrate its features, the code snippet below is for querying a machine’s model and gives us enough info to start using the tool.
strComputer = "."
Set WshShell = WScript.CreateObject("WScript.Shell")
strQuery="SELECT * from Win32_ComputerSystem"
Set col=GetObject("WinMgmts://" & strComputer & "/root/cimv2").ExecQuery(strQuery)
For Each WMIProperty in col
PCModel = WMIProperty.Model
First, I need to select the CIMV2 namespace and then find the win32_computersystem class in the class drop-down box. Without reference to a huge book or the internet, you would struggle to discover the properties in the class without perhaps writing a script. Code creator makes this trivial, with the click of a single button which lists all properties. The model is just one property of many, as you can see in figure 2 below:




Subscribe via e-mail: 
(2 votes, average: 4.00 out of 5)