Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 26, 2016, 12:24:07 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Interesting tool for generating WMI queries  (Read 1957 times)

Vurbal

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 633
  • Mostly harmless
    • View Profile
    • Read more about this member.
    • Donate to Member
Interesting tool for generating WMI queries
« on: March 20, 2014, 10:33:26 AM »
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

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,397
    • View Profile
    • Donate to Member
Re: Interesting tool for generating WMI queries
« Reply #1 on: March 20, 2014, 07:04:43 PM »
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 ...

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,158
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: Interesting tool for generating WMI queries
« Reply #2 on: March 21, 2014, 06:08:13 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.  :)