[jawsscripts] Re: WMI
- From: Soronel Haetir <soronel.haetir@xxxxxxxxx>
- To: jawsscripts@xxxxxxxxxxxxx
- Date: Mon, 13 Aug 2012 19:46:46 -0800
Wow, I just took a look at the MSDN web site for SWbemObjectSet.
There is no way I would have got it working if that's what I had been
going by. I pretty much always use a local install of the docs,
lately I've finally been getting used to the newer system introduced
with vs2010. I'm still not happy with it, but I am learning to
tolerate it.
What I find interesting is that both sets of local documentation I
use, the vs2008 set and the vs2010 set provide complete reference for
the WMI scripting objects, yet the website does not.
On 8/13/12, Stefan Moisei <vortex37@xxxxxxxxx> wrote:
> Thanks Soronel, you rule. It worked. I looked at the msdn page for
> SWbemObjectSet and seen just the item method. The ItemIndex method was
> available only after clicking on the methods link, quite bad design if you
> ask me.
> Also thanks Doug for the code, it seems we can iterate through WMI
> collections.
> -----Original Message-----
> From: Soronel Haetir
> Sent: Tuesday, August 14, 2012 5:06 AM
> To: jawsscripts@xxxxxxxxxxxxx
> Subject: [jawsscripts] Re: WMI
>
> And in the meantime, I got the original script to work:
>
> Script GetMonitorStatus ()
> var
> object oLocator,
> object oWmi,
> object oMonitors,
> object oMonitor
>
> oLocator=CreateObject("WbemScripting.SWbemLocator.1")
> if(!oLocator) Then
> SayString("Failed to create locater")
> return
> EndIf
> SayString("Created locater")
>
> oWmi=oLocator.ConnectServer("", "root\\wmi")
> if(!oWmi) Then
> SayString("Failed to connect to server")
> return
>
> Endif
>
> oMonitors=oWmi.ExecQuery("select * from WmiMonitorBasicDisplayParams",
> "WQL", 0)
> SayInteger(oMonitors.Count)
> oMonitor=oMonitors.ItemIndex(0)
> SayInteger(oMonitor.MaxHorizontalImageSize)
> EndScript
>
> Note the use of the wmi rather than root namespace in the connection,
> and note also the use of ItemIndex rather than [], to index the object
> set (the Item method expects a string selector and I'm really not sure
> of the syntax required since it apparently varies by object -- for
> instance for disks "c:" might be a valid index for use with [])
>
> Anyway, I hope the above helps.
>
> On 8/13/12, Stefan Moisei <vortex37@xxxxxxxxx> wrote:
>> Ok, got a little further with this.
>> It seems I didn't use the correct WMI namespace. Now, the count of the
>> collection is 1, but I can't get that item into a jaws object. On my
>> machine, the following code says "failed to get monitor instance". Tried
>> it
>>
>> both using the Item() method and using brackets.
>>
>> Script GetMonitorStatus ()
>> var
>> object oLocator,
>> object oWmi,
>> object oMonitors,
>> object oMonitor
>> oLocator=CreateObject("WbemScripting.SWbemLocator.1")
>> if !oLocator Then
>> SayString("Failed to create locator")
>> EndIf
>>
>>
>> oWmi=oLocator.ConnectServer(".", "\\root\\wmi")
>> if !oWmi then
>> SayString("failed to create wmi")
>> endIf
>> oMonitors=oWmi.ExecQuery("select * from WmiMonitorBasicDisplayParams")
>> if !oMonitors then
>> SayString("failed to get monitors")
>> endIf
>> SayInteger(oMonitors.Count)
>> oMonitor=oMonitors.Item(0)
>> if !oMonitor then
>> SayString("failed to get monitor instance")
>> endIf
>>
>> ;SayInteger(oMonitor.MaxHorizontalImageSize)
>> EndScript
>> -----Original Message-----
>> From: Soronel Haetir
>> Sent: Tuesday, August 14, 2012 4:00 AM
>> To: jawsscripts@xxxxxxxxxxxxx
>> Subject: [jawsscripts] Re: WMI
>>
>> Okay, I added some test code, and on my machine at least, the locator
>> is created but then the query returns 0 objects.
>>
>> if !oLocator Then
>> SayString("Failed to create locator")
>> return
>> EndIf
>>
>> and then later
>>
>> SayInteger(oMonitors.Count)
>>
>> It's not much but it is a start toward figuring out what's going on.
>>
>> On 8/13/12, Stefan Moisei <vortex37@xxxxxxxxx> wrote:
>>> Thanks Soronel,
>>> Is there any way of debugging those COM calls?
>>> I've made a script using the ProgID you gave me, it obviously doesn't
>>> work,
>>>
>>> and I don't know how to find out why.
>>> The script follows, in case you can spot any error:
>>>
>>> Script GetMonitorStatus ()
>>> var
>>> object oLocator,
>>> object oWmi,
>>> object oMonitors,
>>> object oMonitor
>>> oLocator=CreateObject("WbemScripting.SWbemLocator.1")
>>> oWmi=oLocator.ConnectServer(".", "root")
>>> oMonitors=oWmi.ExecQuery("select * from WmiMonitorBasicDisplayParams",
>>> "WQL", 48)
>>> oMonitor=oMonitors[0]
>>> SayInteger(oMonitor.MaxHorizontalImageSize)
>>> EndScript
>>> -----Original Message-----
>>> From: Soronel Haetir
>>> Sent: Tuesday, August 14, 2012 2:13 AM
>>> To: jawsscripts@xxxxxxxxxxxxx
>>> Subject: [jawsscripts] Re: WMI
>>>
>>> I haven't tried it, but it certainly looks like it should be possible
>>> using the objects rooted at SWbemLocator.
>>>
>>> It looks like the ProgID is "WbemScripting.SWbemLocator.1" (as far as
>>> I can tell that info is not in MSDN, at least not with all the other
>>> info about the scripting interface for WMI).
>>>
>>> Do you have a specific question?
>>>
>>> On 8/13/12, Stefan Moisei <vortex37@xxxxxxxxx> wrote:
>>>> Hi,
>>>> Has anyone used WMI in Jaws Scripting? From what I read until now, it
>>>> seems
>>>> to be accessible via COM, so it should be possible.
>>>> If you did, may you be so kind as to show me how?
>>>> Thanks.
>>>> __________�
>>>>
>>>> View the list's information and change your settings at
>>>> http://www.freelists.org/list/jawsscripts
>>>>
>>>>
>>>
>>>
>>> --
>>> Soronel Haetir
>>> soronel.haetir@xxxxxxxxx
>>> __________�
>>>
>>> View the list's information and change your settings at
>>> http://www.freelists.org/list/jawsscripts
>>>
>>> __________�
>>>
>>> View the list's information and change your settings at
>>> http://www.freelists.org/list/jawsscripts
>>>
>>>
>>
>>
>> --
>> Soronel Haetir
>> soronel.haetir@xxxxxxxxx
>> __________�
>>
>> View the list's information and change your settings at
>> http://www.freelists.org/list/jawsscripts
>>
>> __________�
>>
>> View the list's information and change your settings at
>> http://www.freelists.org/list/jawsscripts
>>
>>
>
>
> --
> Soronel Haetir
> soronel.haetir@xxxxxxxxx
> __________�
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
> __________�
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
>
--
Soronel Haetir
soronel.haetir@xxxxxxxxx
__________�
View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts
Other related posts: