DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Interesting tool for generating WMI queries  (Read 6,911 times)

Vurbal

  • Mostly harmless
  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 653
    • Writer
Interesting tool for generating WMI queries
« on: March 20, 2014, 03:33 PM »
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.

http://technet.microsoft.com/en-us/magazine/2006.01.utilityspotlight.aspx

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.
I learned to say the pledge of allegiance
Before they beat me bloody down at the station
They haven't got a word out of me since
I got a billion years probation
- The MC5

Follow the path of the unsafe, independent thinker. Expose your ideas to the danger of controversy. Speak your mind and fear less the label of ''crackpot'' than the stigma of conformity.
- Thomas J. Watson, Sr

It's not rocket surgery.
- Me


I recommend reading through my Bio before responding to any of my posts. It could save both of us a lot of time and frustration.

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: Interesting tool for generating WMI queries
« Reply #1 on: March 21, 2014, 12:04 AM »
There's the old Scriptomatic v2.0 tool also:

Quote
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.

AutoIt WMI Scriptomatic
Scriptomatic4AutoHotkey
Powershell Scriptomatic
ADSI Scriptomatic

Probably a version for every language ...
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Interesting tool for generating WMI queries
« Reply #2 on: March 21, 2014, 11:08 AM »
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.  :)

Original address: https://www.donationcoder.com/forum/index.php?topic=37560.0