[python-win32] How to find corresponding WMI/COM object for given Windows Registry key?

Tim Golden mail at timgolden.me.uk
Sat Jun 23 17:17:39 CEST 2012


On 23/06/2012 14:03, Radek Holý wrote:
> 2012/6/18 Radek Holý <radekholypublic at gmail.com>:
>> 2012/6/18 Tim Golden <mail at timgolden.me.uk>:
>>> On 18/06/2012 00:58, Radek Holý wrote:
>>>>
>>>> My question is probably poorly formulated.
>>>> In fact -- as I discovered -- some WMI objects reflect their values in
>>>> the Windows Registry keys (for example there is mapping
>>>> “root\cimv2:Win32_OSRecoveryConfiguration.AutoReboot” in
>>>>
>>>> “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\AutoReboot”).
>>>> Is there some *common* attribute of WMI/COM/OLE objects giving the key
>>>> path?
>>>
>>>
>>> I don't believe so. The thing about WMI is that it provides a
>>> uniform and accessible layer on top of quite a lot of lower-level
>>> APIs. In some cases, that's a layer over registry entries; in other
>>> cases it's a layer over an actual API call. It may even be the only
>>> publicly-accessible means of achieving some result.
>>>
>>> As it happens, for *methods* there is sometimes a clue as to the
>>> underlying API. I have exposed this as (for want of a better name) the
>>> provenance attribute of a method class. So if you do this:
>>>
>>> <code>
>>> import wmi
>>>
>>> print wmi.WMI().Win32_Process.Create.provenance
>>>
>>> </code>
>>>
>>> You'll see something like this:
>>>
>>> Win32API|Process and Thread Functions|CreateProcess
>>>
>>> I'm not aware of any such thing for attributes, although it wouldn't
>>> surprise me utterly if there were.
>>
>> I know that the dependence WMI <-> WinReg is not frequent. Saying
>> “common attribute” I thought common to this (reflecting) type of
>> objects. So it seems that it was an exception that I managed to print
>> this thing.
>> Or is it possible that the attribute belongs to underlaying COM or OLE
>> object? (In the pywin32 implementation!)
>>
>> I wonder which object it was... :-/ What a pity that interactive shell
>> does not remember the history of commands after rebooting the
>> computer… :-D
>> --
>> Radek Holý
>> Czech republic
>
>
> Hello,
>
> I was advised to look at the ``MappingStrings`` qualifier. So far it
> seems that the only way is to list ``MappingStrings`` qualifiers of
> all properties.

[... snip code ...]

Thanks for the hint. I'll take a look at that myself with a view
to fitting it into the wmi module

TJG


More information about the python-win32 mailing list