Joe Glines wrote:BTW- I borrowed & tweaked my code from that original post but I can't claim to understand a lick of it (nor can I follow yours) Could you go back and annotate it to help me understand what they are doing?

ROFL. I've seen some of your posts on
http://the-automator.com/ and you're streets ahead of me!
For creating WMI queries from scratch I still tend to use the
Scriptomatic V2 for Win 7 HTA to construct the initial query then check out
AHK - WMI - Snippets (
https://autohotkey.com/boards/viewtopic.php?f=6&t=51&hilit=WMI) to see whether I have the AHK code right.
I'm sure someone will correct me if I'm wrong but, to me, all this means is to run a WMI query against the
Win32_BaseBoard
collection and return the result for the object named
SerialNumber
. If you use
Scriptomatic it will show you every available object available for each collection. Sorry, I don't use WMI often enough to have found a better tool... although I'm sure one or more exists.
Code: [Select all]GeSHi © Codebox Plus
objWMIService := ComObjGet("winmgmts:{impersonationLevel = impersonate}!\\.\root\cimv2")
colItems := objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")._NewEnum
while colItems[objItem]
if objItem.IPAddress[0] = A_IPAddress1
MsgBox % objItem.MACAddress
Similarly, all this means is run a WMI query against all
Win32_NetworkAdapterConfiguration
collections that have
IPEnabled
set to
True
and return the result for the object named
MACAddress
. This way it will catch the
active network adaptor and ignore inactive or pseudo/virtual adapters.
WMI can sometimes be a little flaky, especially now that
PowerShell has gained such a foothold (which is why I've been playing with wrapping PowerShell cmdlets in AHK). Whilst
PowerShell still supports WMI cmdlets, some WMI classes have been deprecated and I guess this trend will continue. Have a read of this
CIM vs. WMI CmdLets – The top reasons I changed over article (
http://maikkoster.com/cim-vs-wmi-cmdlets-the-top-reasons-i-changed/). On the other hand, most WMI queries will remain for some time... and only MS can tell us how long that will be.
Hope this helps...
[quote="Joe Glines"]BTW- I borrowed & tweaked my code from that original post but I can't claim to understand a lick of it (nor can I follow yours) Could you go back and annotate it to help me understand what they are doing? :oops:[/quote]
ROFL. I've seen some of your posts on [url]http://the-automator.com/[/url] and you're streets ahead of me!
For creating WMI queries from scratch I still tend to use the [b]Scriptomatic V2 for Win 7[/b] HTA to construct the initial query then check out [b]AHK - WMI - Snippets[/b] ([url]https://autohotkey.com/boards/viewtopic.php?f=6&t=51&hilit=WMI[/url]) to see whether I have the AHK code right.
[code]While (ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2").ExecQuery("Select * From Win32_BaseBoard")._NewEnum)[objMBInfo]
MsgBox % objMBInfo["SerialNumber"][/code]
I'm sure someone will correct me if I'm wrong but, to me, all this means is to run a WMI query against the [c]Win32_BaseBoard[/c] collection and return the result for the object named [c]SerialNumber[/c]. If you use [b]Scriptomatic[/b] it will show you every available object available for each collection. Sorry, I don't use WMI often enough to have found a better tool... although I'm sure one or more exists.
[code]objWMIService := ComObjGet("winmgmts:{impersonationLevel = impersonate}!\\.\root\cimv2")
colItems := objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")._NewEnum
while colItems[objItem]
if objItem.IPAddress[0] = A_IPAddress1
MsgBox % objItem.MACAddress[/code]
Similarly, all this means is run a WMI query against all [c]Win32_NetworkAdapterConfiguration[/c] collections that have [c]IPEnabled[/c] set to [c]True[/c] and return the result for the object named [c]MACAddress[/c]. This way it will catch the [u]active[/u] network adaptor and ignore inactive or pseudo/virtual adapters.
WMI can sometimes be a little flaky, especially now that [b]PowerShell[/b] has gained such a foothold (which is why I've been playing with wrapping PowerShell cmdlets in AHK). Whilst [b]PowerShell[/b] still supports WMI cmdlets, some WMI classes have been deprecated and I guess this trend will continue. Have a read of this [b]CIM vs. WMI CmdLets – The top reasons I changed over[/b] article ([url]http://maikkoster.com/cim-vs-wmi-cmdlets-the-top-reasons-i-changed/[/url]). On the other hand, most WMI queries will remain for some time... and only MS can tell us how long that will be.
Hope this helps...