I'm using mattn's go-ole package to connect to WMI, I got this working using some examples I found on stack and all is fine until I try to make it work in Win XP. The Microsoft documentation says thatWbemScripting.SWbemLocator
is only available for Vista so I've been trying the winmgmts
method that Microsoft shows for use on VBScript but i'm not getting anywhere.
Here is what I have.
This works on Win 7:
wmiscriptObj, err := oleutil.CreateObject("WbemScripting.SWbemLocator")
This doesn't work in either XP or 7:
wmiscriptObj, err := oleutil.CreateObject("winmgmts:\\\\.\oot\\cimv2")
I get invalid class as an error.
Not sure if this helps explain things but in the past I've used Autoit to query WMI on XP and I can connect with this:
$objWMIService = ObjGet("winmgmts:\\" & $ComputerName & "oot\CIMV2")
Any help would be much appreciated.