Sign in to follow this  
Followers 0
Harry

Problem inspecting results of complex WMI query

3 posts in this topic

I've got a complex WMI query that I can run and inspect with vbs no problem. See snippet below. ==>

****************************

Dim Services, Query, CollectionSet, Collection

Set Services = GetObject("winmgmts:\\myserver\root\sms\site_xxx")

Query = "select sys.name, prg.commandline, adv.programName, ads.LastStatusTime, ads.LastStateName, pkg.name, " & _

"pkg.pkgsourcepath from sms_ClientAdvertisementStatus ads left join sms_r_system sys on sys.ResourceID = ads.ResourceID " & _

"inner join sms_Advertisement adv on ads.AdvertisementID = adv.AdvertisementID " & _

"left join sms_Package pkg on adv.Packageid = pkg.Packageid left join sms_program prg on adv.ProgramName = prg.ProgramName " & _

"where ads.laststatustime > '20081206' and sys.name like 'myPC'"

Set CollectionSet = Services.ExecQuery(Query,,48)

For Each Collection In CollectionSet

Wscript.Echo Collection.ads.Properties_("LastStateName")

Next

****************************

Unfortunately, when I convert that to AutoIt, I get zip. i.e. when I run this... ==>

****************************

Dim $Services, $Query, $CollectionSet, $Collection

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler

$Services = objget("winmgmts:\\myserver\root\sms\site_xxx")

$Query = "select sys.name, prg.commandline, adv.programName, ads.LastStatusTime, ads.LastStateName, pkg.name, " & _

"pkg.pkgsourcepath from sms_ClientAdvertisementStatus ads left join sms_r_system sys on sys.ResourceID = ads.ResourceID " & _

"inner join sms_Advertisement adv on ads.AdvertisementID = adv.AdvertisementID " & _

"left join sms_Package pkg on adv.Packageid = pkg.Packageid left join sms_program prg on adv.ProgramName = prg.ProgramName " & _

"where ads.laststatustime > '20081206' and sys.name like 'myPC'"

$CollectionSet = $Services.ExecQuery($Query)

For $Collection In $CollectionSet

MsgBox(4096,"Test",$Collection.ads.Properties_("LastStateName"))

Next

Exit

; This is my custom error handler

Func MyErrFunc()

$HexNumber=hex($oMyError.number,8)

Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _

"Number is: " & $HexNumber & @CRLF & _

"Windescription is: " & $oMyError.windescription )

$g_eventerror = 1 ; something to check for when this function returns

Endfunc

****************************

... the code ends without having issued a single MsgBox. There's no object error either. I suspect that vbs can see that the resulting object from the query contains embedded object results, but AutoIt can't.

Are there any AutoIt methods or properties that I can inspect in order to see what AutoIt is making of the result? I know that it runs the query; it just doesn't seem to be able to handle the "object" that is returned.

I have a suspicion that WQL doesn't support queries across classes, but I've got this code to work in vbs and Perl so it's a real shame that I can't get it to work in the language of choice for this particular project.

Any ideas? Many thanks in anticipation.

Share this post


Link to post
Share on other sites



Should this line have been like this, to match the parameters given in the VBS example?

$CollectionSet = $Services.ExecQuery($Query, "", 48)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Harry,

Any luck I'm curious if you got this working? I've been doing some SMS/SCCM stuff in AutoIt too.

Terry

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0