Give us a call at 262.299.4606 to discuss how FastTrack can help your organization or email us here

FastTrack Automation Studio 11 is now available. Click here to download now.
FastTrack Backup

Working with Windows Management Instrumentation (WMI)

Windows Management Instrumentation (WMI) is Microsoft's version of the industry standard Web-based Enterprise Management (WBEM), which uses the Common Information Model (CIM) industry standard to represent managed objects.

In layman's terms this means that Microsoft has made an abstraction layer on top of, among other things, hardware and software information and you get an sql-like syntax to get or set information. This is a very good thing, because if you use the Windows API directly, no two information is retrieved the same way. As with all abstraction there is a price to pay, which in this case is performance. But luckily you can use built-in FastTrack functions for common operations instead of using WMI and this way you do not pay the penalty. But if you move outside querying common information or you need to invoke methods, you must use WMI.

If you are not familiar with WMI, please have a look at the official Microsoft WMI page.

Download FastTrack Automation Studio


Working with Windows Management Instrumentation (WMI)

Department of Commerce Booking Kpmg Aspen Dental Hamilton Beach Toyota Disney Kawasaki Goodyear Maersk NOAA

Create a logon script with your own logo in 30 minutes without writing a single line of code! Visit

Using WMI to get a single value

If you go to the "WMI" node in the Engine Browser tree in the script editor, you will find only two sub-nodes. One is the function that retrieves one WMI value and one is the collection that retrieves multiple values. And essentially, this is all you need, because this is enough to get information from WMI. If you are doing very advanced WMI scripting, you may need to work on WMI objects, and this is described further down.

If we wanted to get the total memory installed, we would first have to find out in what WMI class we need, which we can see here: Computer System Hardware Classes. In this case need the TotalPhysicalMemory from the Win32_ComputerSystem class. We know we just need to get one value from WMI, so we can just use the WMIQuery function like this:

ShowMessage [WMIQuery Select TotalPhysicalMemory From Win32_ComputerSystem]

And voila, we have the total memory. For demonstration purposes, we are just displaying the value on the screen. In real life, the WMIQuery function could be used like this: "Set MyVariable = [WMIQuery Select TotalPhysicalMemoryFrom Win32_ComputerSystem]" to save the information in a variable for later use.

But here is the one thing you must know, when using WMI with FastTrack: If there is a native function to get the same information - use it. The native version will in many cases give you this information in a few milliseconds, where the WMI layer will take seconds to get the same information. Before you start to use WMI, try to search for a native function with the F9 key (Search Engine Browser). Searching for "memory" will show us that there is a function called "TotalMemory". So we can instead simply go:

ShowMessage [TotalMemory]

Now there are a number of advantages using the native version. First of all, they are usually quicker and secondly, they are often formatted. Where the WMI version will give you 4080713728 (bytes) on a 4 gigabyte machine, the native version will give you a more useful 4080 (megabytes).

Using WMI to get multiple values

In some cases we would need more than one value from a query. In this case we need the WMIValues collection. This could be relevant, if we wanted to collect all disk drives in a computer. We could log this information to a file or store it elsewhere, but for demonstration purposes, we will just show the retrieved names of the drives:

ForEach Model in [WMIValues SELECT model from Win32_DiskDrive]

  ShowMessage [Var Model]

End ForEach

Using WMI to get multiple properties

If we need more than one property in a WMI query, we need to work on WMI objects through COM. Refer to this page for documentation on using COM with FastTrack.

As shown in the article, we can create an instance of the Win32_LogicalDisk class and go through the results. In the example below, we are displaying the property "Name" of each disk object, but all other properties and methods on the Win32_LogicalDisk object can be used through the ObjectValue function, as we used the star-notation (*).

ForEachObject Drive in CreateWMIObject("Select * from Win32_LogicalDisk")

  ShowMessage [ObjectValue Drive.Name]

End ForEachObject

If the example, we are using one property. If we need to invoke a method, we can do this the same way we use properties. The best example on using methods is the Hyper-V Controller script shown here, where the "RequestStateChange" method is invoked to stop and start Hyper-V machines.
Outlook Signature Generation

Outlook Signatures

Build mass-deployable Outlook signatures using a Word-like designer. More
Graphical Logon Scripts

Codeless Logon Scripts

Build graphical logon scripts with your own logo by pure point and click. More
IP Printing

Kill your print servers

Print to IP printers directly. More
Software Deploy

Software Deploy and Inventory

Push software without a management server and inventory to the cloud. More
Zero Touch Thin PC

Tired of Desktop Authority?

Same features - less complexity. More
FastTrack Automation Studio Video
Download FastTrack Automation Studio
Laptop Backups

Lockdown Local Admins

Revoke local admins rights and have users request ad-hoc access under full audit. More

Rating: 5 out of 5

"Use this as a replacement for VBScript and PowerShell"

"It's easy to include attractive GUI elements in FastTrack scripts, beyond the basic dialog boxes and text input that VBScript offers ... Another powerful feature is the ability to distribute scripts as Windows Installer (.msi) or standard .exe files. Although interesting in its own right, this ability results in a much more intriguing capability: to repackage -- or wrap -- software installers as .msi files without using snapshots. If you've ever created an .msi installer file from before-and-after system snapshots, for use with a software distribution system such as Group Policy or System Center Configuration Manager (SCCM), then you know how hit-and-miss the results can be."

Read full review

Rating: 8 out of 10

"Faster than the rest"

"We found the FastTrack syntax to be more transparent and easier to learn than Microsoft's PowerShell – the editor in particular provided good support in this regard. Scripting mode offers a large number of options from the command set through to simple output of graphical elements, which cannot be achieved at all with PowerShell or other solutions or only with a significantly greater level of effort."

"Anyone wanting to tackle the many hurdles in everyday admin and especially anyone for whom logon scripts and client automation is a priority will benefit from the variety of functions offered by FastTrack."

Review in English      Review in German

Need to deploy Software the simplest possible way? Check this page for more info.