Snippets Project Page
Author: Dazuz
Added: 4y
Updated: 4y
mIRC: 7.55
Hits: 1,172
Downloads: 18
Review: westor
Size: 19.22KB
3 0
Login to vote.
WMI Explorer
v2.2
A little script for WMI (Windows Management Instrumentation) exploration.
Allows you to see all available WMI namespaces, classes, properties and values.
Includes a simple code creator tool for examples.
Download
JSON
▲ Review
▲ Log
▼ Source
/* Windows Management Instrumentation Explorer for mIRC v7.55+ Version: 2.2 Coded by: Dazuz @ QuakeNet 2.2 (2020-03-31) - Improvements to the way filtering is handled. 2.1 (2020-03-28) - Properties load timer could sometimes keep running after new class had been selected. - An error would occur when a classless namespace was selected. 2.0 (2020-03-28) - Initial release. 1.0 (2018-07-27) - https://forums.mirc.com/ubbthreads.php/topics/263422/re-com-wmi-getting-all-properties-of-a-class#Post263422 */ ;This alias creates $scriptdirCube.ico file. Feel free to remove the alias, it won't break anything important. alias wmie.createicon { set -l %icon $qt($scriptdirCube.ico) if (!$isfile(%icon)) { bset -t & 1 Y2BgBEIBAQYgUGDIYGFgEAOyNIBYACzCAJQFkQwMDiwMGOD///+MtMBrt+9oRMak6steN+U/MiZkDrq+zMPL/6c/PPSfGHOw6YNhdP3I5sD0Y9NHSD8II+vHpnco63/x8+v/vS/uwjGx+kH6YBhZPzZzkPXPO7sHRS8u/SDce2wTin6YGejm4NKHrheXOaTow2UOqfpIxaASgBIMAA== if ($decode(&,bm)) && ($decompress(&,bm1)) && ($sha1(&,1) == ae378536e1f7af22066cb722dd04739a5a7fe8a4) bwrite %icon 0 & } } on *:load: { if ($version < 7.55) { echo $color(info) -at * Unsupported mIRC version, please update to $v2 or newer. unload -rs $qt($script) } else { echo $color(info) -st * Windows Management Instrumentation Explorer loaded! Type /WMIE to open the explorer. wmie.createicon } } on *:unload: { .remove $qt($scriptdirCube.ico) if ($dialog(wmie)) dialog -c wmie else wmie.close } on *:exit:unset %wmie.* alias -l wmie.close { .timerwmie.* off unset %wmie.* if ($dialog(wmie.creator)) dialog -c wmie.creator if ($com(wmie.vb)) .comclose wmie.vb if ($com(wmie.open)) .comclose wmie.open if ($com(wmie.locator)) .comclose wmie.locator if ($com(wmie.properties)) .comclose wmie.properties } menu menubar { WMI Explorer .$+(WMI Explorer,$chr(9),/wmie):wmie .- .Uninstall:if ($input(Do you really want to uninstall WMI Explorer?,yqu,WMI Explorer)) unload -rs $qt($script) } dialog -l wmie { title "Windows Management Instrumentation Explorer - /wmie" icon $scriptdirCube.ico size -1 -1 673 433 option map edit "", 1, 3 420 667 11, autohs read text "Looking up namespaces...", 100, 4 2 180 10 list 101, 3 13 190 390, size edit "", 102, 3 406 190 11, autohs limit 512 list 199, 10 440 10 10, size hide text "Select a namespace", 200, 197 2 180 10 list 201, 196 13 190 390, size edit "", 202, 196 406 190 11, autohs limit 512 list 299, 193 440 10 10, size hide text "Select a class", 300, 390 2 270 10 edit "", 301, 389 13 280 391, autohs autovs hsbar multi read return rich vsbar edit "", 302, 389 406 197 11, autohs limit 512 check "Hide $null properties", 303, 591 406 79 11 list 399, 373 440 10 10, size hide menu "File", 500 item "Exit", 501, 500, ok menu "Copy", 600 item "Selected namespace", 601, 600 item "All namespaces", 602, 600 item break, 603, 600 item "Selected class", 604, 600 item "All classes", 605, 600 menu "Tools", 700 item "WMI Code Creator", 701, 700 menu "Help", 800 item About, 801, 800 } alias wmie { if ($dialog(wmie)) dialog -c wmie elseif ($isadmin) || ($input($+(mIRC is currently not running in administrator mode,$chr(44) this means the enumeration process will take longer,$chr(44) and some of the namespaces will not appear in the list.,$str($crlf,2),Would you like to continue?),qyu,WMI Explorer)) dialog -dm wmie wmie } on *:dialog:wmie:init:0: { did -c wmie 303 if ($com(wmie.vb)) .comclose wmie.vb if ($com(wmie.open)) .comclose wmie.open if ($com(wmie.locator)) .comclose wmie.locator if ($com(wmie.properties)) .comclose wmie.properties .comopen wmie.vb MSScriptControl.ScriptControl .comopen wmie.open WbemScripting.SWbemLocator .comopen wmie.locator WbemScripting.SWbemLocator did -ra wmie 1 winmgmts:{impersonationLevel=impersonate}!\\.\ .timerwmie.continue -om 1 0 wmie.loadnamespaces $com(wmie.vb,Language,4,bstr,VBScript) :error | if ($error) wmie.error $v1 } alias -l wmie.error { reseterror if ($dialog(wmie)) dialog -c wmie noop $input(An error occurred: $1-,ohu,Windows Management Instrumentation Explorer) } alias -l wmie.wmipath did -ra wmie 1 winmgmts:{impersonationLevel=impersonate}!\\.\ $+ $iif($did(101).seltext,$v1 $+ $iif($did(201).seltext,: $+ $v1)) alias -l wmie.loadnamespaces { set -l %v Dim r:Call e("root"):Sub e(n):On Error Resume Next:r=r&n&" ":For Each i In GetObject("winmgmts:{impersonationLevel=impersonate}\\.\"&n).ExecQuery("SELECT * FROM __NAMESPACE",,48):If i.Count > 0 Then:Call e(n&"\"&i.Name):End If:Next:End Sub noop $com(wmie.vb,ExecuteStatement,1,bstr,%v) $com(wmie.vb,eval,3,bstr*,r) $com(wmie.vb,&).result $com(wmie.vb,reset,1) set -l %x 1 while ($bfind(&,%x,32)) { did -a wmie 199 $bvar(&,%x - $v1).text %x = $v1 + 1 } filter -iotu 1 32 wmie 199 wmie 101 did -a wmie 100 Namespaces ( $+ $bytes($filtered,b) out of $bytes($filtered,b) $+ ): :error | if ($error) wmie.error $v1 } on *:dialog:wmie:sclick:101: { wmie.wmipath if ($did(101).seltext) { did -ra wmie 200 Looking up classes... did -r wmie 201,299 set -l %v On Error Resume Next:For Each i in GetObject("winmgmts:{impersonationLevel=impersonate}\\.\<namespace>").ExecQuery("SELECT * FROM meta_class",,48):If i.Properties_.Count > 0 Then:r=r&i.Path_.Class&" ":End If:Next noop $com(wmie.vb,ExecuteStatement,1,bstr,$replacex(%v,<namespace>,$did(101).seltext)) $com(wmie.vb,eval,3,bstr*,r) $com(wmie.vb,&).result $com(wmie.vb,reset,1) set -l %x 1 while ($bfind(&,%x,32)) { did -a wmie 299 $bvar(&,%x - $v1).text %x = $v1 + 1 } filter -ciotu 1 32 wmie 299 wmie 201 $+(*,$did(202),*) did -a wmie 200 Classes ( $+ $bytes($filtered,b) out of $bytes($did(299).lines,b) $+ ) did -e wmie 202 if ($com(wmie.locator)) .comclose wmie.locator noop $com(wmie.open,ConnectServer,1,bstr,.,bstr,$did(101).seltext,dispatch* wmie.locator) } :error | if ($error) wmie.error $v1 } on *:dialog:wmie:dclick:101:clipboard $did(101).seltext on *:dialog:wmie:edit:102: { set -l %s $did(101).seltext filter -ciotu 1 32 wmie 199 wmie 101 $+(*,$did(102),*) did -a wmie 100 Namespaces ( $+ $bytes($filtered,b) out of $bytes($did(199).lines,b) $+ ): if ($didwm(101,%s)) did -c wmie 101 $v1 else { did -a wmie 200 Select a namespace did -a wmie 300 Select a class did -r wmie 201,299,301,399 did -e wmie 302,303 .timerwmie.load off } wmie.wmipath } on *:dialog:wmie:sclick:201: { wmie.wmipath if ($did(201).seltext) { did -r wmie 399 did -b wmie 302,303 did -ra wmie 301 Looking up properties... did -a wmie 300 Looking up properties... set -l %v On Error Resume Next:For Each i In GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\<namespace>:<class>").Properties_:r=r&i.Name&" ":Next noop $com(wmie.vb,ExecuteStatement,1,bstr,$replacex(%v,<namespace>,$did(101).seltext,<class>,$did(201).seltext)) $com(wmie.vb,eval,3,bstr*,r) %wmie.properties = $sorttok($com(wmie.vb).result,32,a) set -l %n $numtok(%wmie.properties,32) noop $com(wmie.vb,reset,1) if (%n) { did -o wmie 301 1 Looking up properties... %n found. $+ $crlf did -a wmie 301 Looking up instances... if ($com(wmie.properties)) .comclose wmie.properties noop $com(wmie.locator,ExecQuery,1,bstr,SELECT * FROM $did(201).seltext,dispatch* wmie.properties) $com(wmie.properties,Count,3) if ($com(wmie.properties).result) { %wmie.t = $v1 did -o wmie 301 2 Looking up instances... $bytes(%wmie.t,b) found. $+ $crlf %wmie.x = 1 did -a wmie 301 Loading instance 1 of %wmie.t $+ ... .timerwmie.load -oh 0 0 wmie.loadinstances %wmie.properties } else { did -ra wmie 301 $+($did(201).seltext has $bytes(%n,b) properties in 0 instances:,$str($crlf,2),$replacex(%wmie.properties,$chr(32),$crlf)) did -a wmie 300 %n properties in 0 instances: .timerwmie.load off } } else { noop $com(wmie.locator,ExecQuery,1,bstr,SELECT * FROM $did(201).seltext,dispatch* wmie.properties) $com(wmie.properties,Count,3) if ($com(wmie.properties).result isnum) set -l %i $v1 else set -l %i 0 did -ra wmie 301 $did(201).seltext has 0 properties in %i instance(s). did -a wmie 300 0 properties in %i instance(s): } } :error | if ($error) wmie.error $v1 } alias -l wmie.loadinstances { if (%wmie.x <= %wmie.t) { wmie.loadproperties $* did -o wmie 301 3 Loading instance %wmie.x of %wmie.t $+ ... inc %wmie.x } else wmie.stop } alias -l wmie.stop { did -e wmie 302,303 .timerwmie.load off if ($com(wmie.properties)) .comclose wmie.properties wmie.filterinstances :error | if ($error) wmie.error $v1 } alias -l wmie.loadproperties did -a wmie 399 %wmie.x $1 $comval(wmie.properties,%wmie.x,$1) alias -l wmie.filterinstances { did -rh wmie 301 unset %wmie.i %wmie.p %wmie.c = 0 if ($did(wmie,303).state) filter -iktu 1 32 wmie 399 wmie.filter $+(*,$did(wmie,302),*) else filter -iktu 1 32 wmie 399 wmie.nonullfilter $+(*,$did(wmie,302),*) if (%wmie.p) { inc %wmie.c did -a wmie 301 $+(Instance $chr(35),%wmie.i,:,$crlf) did -a wmie 301 $replacex(%wmie.p,$chr(1),$crlf) } did -a wmie 300 $bytes($numtok(%wmie.p,1),b) out of $bytes($numtok(%wmie.properties,32),b) properties in $bytes(%wmie.c,b) out of $bytes(%wmie.t,b) instance(s): did -v wmie 301 } alias -l wmie.filter tokenize 32 $1 | if ($1 != %wmie.i) wmie.instance | %wmie.i = $1 | if ($3 != $null) %wmie.p = $addtok(%wmie.p,$2 = $3-,1) alias -l wmie.nonullfilter tokenize 32 $1 | if ($1 != %wmie.i) wmie.instance $1 | %wmie.i = $1 | %wmie.p = $addtok(%wmie.p,$2 = $3-,1) alias -l wmie.instance { if (%wmie.p) { inc %wmie.c did -a wmie 301 $+(Instance $chr(35),%wmie.i,:,$crlf) did -a wmie 301 $replacex(%wmie.p,$chr(1),$crlf) $+ $str($crlf,2) unset %wmie.p } } on *:dialog:wmie:dclick:201:clipboard $did(201).seltext on *:dialog:wmie:edit:202: { set -l %s $did(201).seltext filter -ciotu 1 32 wmie 299 wmie 201 $+(*,$did(202),*) did -ra wmie 200 Classes ( $+ $bytes($filtered,b) out of $bytes($did(299).lines,b) $+ ): if ($didwm(201,%s)) did -c wmie 201 $v1 else { did -a wmie 300 Select a class did -r wmie 301,399 did -e wmie 302,303 .timerwmie.load off } wmie.wmipath } on *:dialog:wmie:edit:302:.timerwmie.filter -om 1 100 wmie.filterinstances on *:dialog:wmie:sclick:303:wmie.filterinstances on *:dialog:wmie:close:0:wmie.close on *:dialog:wmie:menu:601:clipboard $did(101).seltext on *:dialog:wmie:menu:602: { set -l %x 1 clipboard while ($did(101,%x) != $null) { clipboard -an $v1 | inc %x } } on *:dialog:wmie:menu:604:clipboard $did(201).seltext on *:dialog:wmie:menu:605: { set -l %x 1 clipboard while ($did(201,%x) != $null) { clipboard -an $v1 | inc %x } } on *:dialog:wmie:menu:701: { if ($did(101).seltext) && ($did(201).seltext) noop $dialog(wmie.creator,wmie.creator,-4) else noop $input(Select a namespace and class first.,wou,WMI Code Creator) } on *:dialog:wmie:menu:801: { set -l %msg Windows Management Instrumentation Explorer v2.2\n\nCoded by: Dazuz @ QuakeNet noop $input($replacex(%msg,\n,$crlf),oiu,Windows Management Instrumentation Explorer) } dialog -l wmie.creator { title "WMI Code Creator" icon $scriptdirCube.ico size -1 -1 515 254 option map text "Namespace:", 1, 0 5 50 11, right edit "", 2, 55 4 200 11, autohs read text "Class:", 3, 0 20 50 11, right edit "", 4, 55 19 200 11, autohs read text "Property:", 5, 0 61 50 11, right list 6, 55 60 200 155, check size text "Qualifier:", 7, 0 219 50 11, right edit "", 8, 54 219 180 11, autohs limit 1024 link "Help", 9, 238 219 18 11 edit "", 10, 260 4 250 226, autohs autovs hsbar multi read vsbar button "Close", 11, 420 234 90 16, ok button "Copy", 13, 329 234 90 16 check "First instance only", 14, 55 33 72 11 check "Leave wmi.locator COM open", 15, 55 45 106 11 link "Help", 16, 162 46 18 11 } alias wc dialog -m wmie.creator wmie.creator on *:dialog:wmie.creator:init:0: { did -a wmie.creator 2 $did(wmie,101).seltext did -a wmie.creator 4 $did(wmie,201).seltext did -a wmie.creator 6 All properties did -s wmie.creator 6 1 %wmie.all = 1 didtok wmie.creator 6 32 %wmie.properties wmie.generate } on *:dialog:wmie.creator:sclick:6: { if ($did(6,1).cstate) && (!%wmie.all) { %wmie.all = 1 set -l %x 1 while ($did(6,%x).csel) { if ($v1 != 1) did -l wmie.creator 6 $v1 else inc %x } } else { unset %wmie.all did -l wmie.creator 6 1 } wmie.generate } on *:dialog:wmie.creator:edit:8:wmie.generate on *:dialog:wmie.creator:sclick:9: { set -l %msg The qualifier will be added to the end of the "SELECT * FROM *" WQL query line. This allows you to limit the number of instance results, which speeds up the lookup.\n\nAs an example, you could use:\nWHERE Name="_Total"\nTo limit the retreived instances to the one that has a property called "Name" with a value "_Total."\n\nNote: you will need to escape some characters, like quotation marks and backslash, in the WQL query. You can escape them with backslash, as an example: \\\n\nWould you like to open the WQL Microsoft Docs page? if ($input($replacex(%msg,\n,$crlf),qyu,WMI Code Creator)) url https://docs.microsoft.com/en-us/windows/win32/wmisdk/wql-sql-for-wmi } on *:dialog:wmie.creator:sclick:14,15:wmie.generate alias -l wmie.generate { if (!$did(6,0).csel) did -s wmie.creator 6 1 did -r wmie.creator 10 wmie.did alias mywmi $chr(123) if ($did(15).state) { wmie.did if (!$com(wmi.locator)) $chr(123) wmie.did .comopen wmi.open WbemScripting.SWbemLocator wmie.did .comclose wmi.open $!com(wmi.open,ConnectServer,1,bstr,.,bstr, $+ $did(2) $+ ,dispatch* wmi.locator) wmie.did $chr(125) } else { wmie.did .comopen wmi.open WbemScripting.SWbemLocator wmie.did .comclose wmi.open $!com(wmi.open,ConnectServer,1,bstr,.,bstr, $+ $did(2) $+ ,dispatch* wmi.locator) } if ($did(6,1).cstate) && (!$did(8)) { set -l %tokenize 32 set -l %properties $gettok($didtok(6,32),3-,32) if ($did(15).state) set -l %query noop $!com(wmi.locator,InstancesOf,1,bstr, $+ $did(4) $+ ,dispatch* wmi.properties) else set -l %query .comclose wmi.locator $!com(wmi.locator,InstancesOf,1,bstr, $+ $did(4) $+ ,dispatch* wmi.properties) wmie.did set -l % $+ properties %properties } else { set -l %q $did(4) $did(8) if ($did(6,1).cstate) { set -l %tokenize 32 set -l %properties $gettok($didtok(6,32),3-,32) if ($did(15).state) set -l %query noop $!com(wmi.locator,ExecQuery,1,bstr,SELECT * FROM %q $+ ,dispatch* wmi.properties) else set -l %query .comclose wmi.locator $!com(wmi.locator,ExecQuery,1,bstr,SELECT * FROM %q $+ ,dispatch* wmi.properties) wmie.did set -l % $+ properties %properties } else { set -l %x 1 set -l %properties while ($did(6,%x).csel) { %properties = %properties $did(6,$v1) inc %x } set -l %tokenize 44 wmie.did set -l % $+ properties $replacex(%properties,$chr(32),$chr(44)) if ($did(15).state) set -l %query noop $!com(wmi.locator,ExecQuery,1,bstr,SELECT % $+ properties FROM %q $+ ,dispatch* wmi.properties) else set -l %query .comclose wmi.locator $!com(wmi.locator,ExecQuery,1,bstr,SELECT % $+ properties FROM %q $+ ,dispatch* wmi.properties) } } if ($did(14).state) { wmie.did %query wmie.did echo -a Retrieving $!numtok(%properties, $+ %tokenize $+ ) properties(s) from 1 instance from $did(4) class in $did(2) namespace wmie.did tokenize %tokenize % $+ properties wmie.did while ($1) $chr(123) wmie.did echo -a Instance $!chr(35) $!+ 1: $!1 = $!comval(wmi.properties,1,$1) wmie.did tokenize 32 $!2- wmie.did $chr(125) } else { wmie.did %query $!com(wmi.properties,Count,3) wmie.did set -l % $+ instances $!com(wmi.properties).result wmie.did echo -a Retrieving $!numtok(%properties, $+ %tokenize $+ ) properties(s) from % $+ instances instances from $did(4) class in $did(2) namespace wmie.did set -l % $+ x 1 wmie.did while (%x <= % $+ instances) $chr(123) wmie.did tokenize %tokenize % $+ properties wmie.did while ($1) $chr(123) wmie.did echo -a Instance $!+($chr(35),%x,:) $!1 = $!comval(wmi.properties,%x,$1) wmie.did tokenize 32 $!2- wmie.did $chr(125) wmie.did inc % $+ x wmie.did $chr(125) } wmie.did .comclose wmi.properties wmie.did :error wmie.did if ($error) $chr(123) wmie.did if ($com(wmi.open)) .comclose wmi.open wmie.did if ($com(wmi.locator)) .comclose wmi.locator wmie.did if ($com(wmi.properties)) .comclose wmi.properties wmie.did $chr(125) wmie.did $chr(125) did -c wmie.creator 10 1 } alias -l wmie.did did -a wmie.creator 10 $1- $+ $crlf on *:dialog:wmie.creator:sclick:13: { set -l %x 2 clipboard -n $did(10,1) while ($did(10,%x)) { clipboard -an $did(10,%x) inc %x } } on *:dialog:wmie.creator:sclick:16: { set -l %msg If you need to retreive information multiple times from the same namespace, leaving "wmi.locator" COM open will make the lookups faster.\n\nNote: you should rename the "wmi.locator" COM to avoid conflicts with other WMI scripts. noop $input($replacex(%msg,\n,$crlf),iou,WMI Code Creator) }
Changelog:
2.2 (2020-03-31)
- Improvements to the way filtering is handled.
2.1 (2020-03-28)
- Properties load timer could sometimes keep running after new class had been selected.
- An error would occur when a classless namespace was selected.
2.0 (2020-03-28)
- Initial release.
1.0 (2018-07-27)
- https://forums.mirc.com/ubbthreads.php/topics/263422/re-com-wmi-getting-all-properties-of-a-class#Post263422
2.2 (2020-03-31)
- Improvements to the way filtering is handled.
2.1 (2020-03-28)
- Properties load timer could sometimes keep running after new class had been selected.
- An error would occur when a classless namespace was selected.
2.0 (2020-03-28)
- Initial release.
1.0 (2018-07-27)
- https://forums.mirc.com/ubbthreads.php/topics/263422/re-com-wmi-getting-all-properties-of-a-class#Post263422
Review: westor
This tool is fantastic !!! very helpful and useful , it has been a really great job..
The only negative is that is taking too long to load.. (i can understand why) so give it some time to load, mine took ~30secs.
- LIKE !
This tool is fantastic !!! very helpful and useful , it has been a really great job..
The only negative is that is taking too long to load.. (i can understand why) so give it some time to load, mine took ~30secs.
- LIKE !
Comments (4)
Mar 28th, 2020 - By: westor
Admin
Reply:
Mar 29th, 2020 - By: Dazuz
Thanks! Fixed it that one, and one like it. It's somewhat careless with the COM objects, so there's just the general error handling where it kills the whole thing on error.
Apr 4th, 2020 - By: westor
Admin
One other small issue is when you change namespaces item from the list then the properties are not cleared.
Image Example: https://i.imgur.com/nCnyrp9.png
Image Example: https://i.imgur.com/nCnyrp9.png
Reply:
Apr 5th, 2020 - By: Dazuz
That is on purpose. It can be somewhat confusing, but loading properties can take a long time, so I wanted to keep the data available. If you're hopping around the namespaces and whatnot, I thought it would be nice to be able to see the last properties result.