ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Interesting tool for generating WMI queries


While I was searching for a way to read shortcut (lnk) file properties in C# (why no I haven't torn out _all_ my hair, but thanks for asking) I stumbled across a nice little GUI for generating WMI queries called WMI Code Creator. It can be used either to enumerate the WMI namespaces, classes, methods, and qualifiers on a given computer (local or remote) or to actually generate C#, VB.NET, or VBScript code for running queries against them via WSH.

I haven't gotten around to testing the code at all, or even attempted to browse the WMI providers on a remote machine for that matter. And of course WSH is deprecated in favor of PowerShell anyway. At the very least, though, the WMI browsing functionality seems useful. There's also a PowerShell based WMI browser that's probably more useful for that. Since PowerShell was introduced shortly before the end of my days as an IT monkey I can't seem to be bothered to put the time and effort into messing with it though.

There's the old Scriptomatic v2.0 tool also:

Scriptomatic 2.0 isn’t limited to writing just VBScript scripts; instead, Scriptomatic 2.0 can write scripts in Perl, Python, or JScript as well.
--- End quote ---

AutoIt WMI Scriptomatic
Powershell Scriptomatic
ADSI Scriptomatic

Probably a version for every language ...

WMI is slow compared to WinAPI calls.  But it can get around some hairy obstacles.  One example I ran into was getting the "home folder" of the program that owns the active window.  Just a hotkey convenience toy that gets the path of the executable that owns the window and chops it at the last '\'.  Easy except for 32 vs 64 bit clash.  The WinAPI calls match up with either 32 or 64 bit depending on the caller's compile.

WMI can get the answer whether the caller is 32 bit or 64 bit.  Not good for tight loops such as enumerating all the window owners.  But you can't have everything.  :)

Thanks to both of you for posting these links.  I'm sure I'll find some interesting stuff using these tools.  :)


[0] Message Index

Go to full version