Python library - WMI.py RegistryValueChangeEvent
shrivastavkhyati at gmail.com
Tue Apr 7 16:15:21 CEST 2015
Thanks for taking a look, Chris.
The error trace:
traceback (most recent call last):
File "MonitorRegistry.py", line 18, in <module>
process_created = watcher()
File "C:\Python27\lib\site-packages\wmi.py", line 1195, in __call__
File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error
raise klass (com_error=err)
_wmi: <x_wmi: Unexpected COM Error (-2147352567, 'Exception occurred.', (0, u'SWbemPropertySet', u'Not found ', None, 0, -2147217406), None)>
when I debugged this is the module that throws the exception:
wmi.py [Line 1178-1195]
def __call__ (self, timeout_ms=-1):
"""When called, return the instance which caused the event. Supports
timeout in milliseconds (defaulting to infinite). If the watcher
times out, :exc:`x_wmi_timed_out` is raised. This makes it easy to support
watching for multiple objects.
event = self.wmi_event.NextEvent (timeout_ms)
return _wmi_event (event, None, self.fields)
return _wmi_event (
_wmi_object (event, property_map=self._event_property_map),
self.is_extrinsic returns false and event.Properties_("TargetInstance").Value throws the exception
Here is the entire(minimal) code:
c = wmi.WMI ()
raw_wql = "SELECT * FROM RegistryValueChangeEvent WHERE Hive='HKEY_LOCAL_MACHINE' AND KeyPath='Software\\\\Temp' AND ValueName='Name'"
watcher = c.watch_for(raw_wql=raw_wql,wmi_class = "__ExtrinsicEvent")
process_created = watcher()
print 'value changed'
I have already emailed - Tim Golden <mail at timgolden.me.uk>
Any other group that I can reach to?
On Monday, April 6, 2015 at 7:50:37 PM UTC-4, Chris Angelico wrote:
> On Tue, Apr 7, 2015 at 8:02 AM, Khyati <shrivastavkhyati at gmail.com> wrote:
> > I have a question about RegistryValueChangeEvent that I have not been able to find an answer to on the internet so far. I would appreciate any help since I have already spent a lot of time finding any material that explains this:
> > What I am trying to do:
> > - create an event when a value for a registry key changes
> Thanks for being clear about this part! Unfortunately, there are a few
> other parts that aren't clear yet, so hopefully you can expand on your
> question a bit.
> > How I am doing it:
> >>raw_wql = "SELECT * FROM RegistryValueChangeEvent WHERE Hive='HKEY_LOCAL_MACHINE' AND KeyPath='Software\\\\Temp' AND ValueName='Name\'"
> Tip: Try adding "print(raw_wql)" just underneath this line, to see if
> you're getting back what you really want. The backslash at the end of
> ValueName is not currently doing anything.
> >>watcher = c.watch_for(raw_wql=raw_wql,wmi_class = "__ExtrinsicEvent")
> >>while TRUE:
> >> process_created = watcher()
> This code isn't complete. Can you post a complete (and minimal)
> example piece of code?
> > Problem:
> > the _wmi_event object returned is not coming back as Extrinsic event -
> > So, in wmi.py, in class _wmi_watcher:
> > "self.is_extrinsic" returns false and I get an exception from the else part - [line 1186 - 1195]
> It'd help hugely if you could post the entire traceback here - what
> exception you're getting, and the exact lines that produce it.
> > What I need
> > - Any reference/idea/explanation on => why does RegistryValueChangeEvent returns as a Non-Extrinsic event? even though it has been derived from __ExtrinsicEvent
> > Other information:
> > Running on Windows 8 64 Bit
> >>>> platform.machine()
> > 'AMD64'
> >>>> platform.architecture()
> > ('64bit', 'WindowsPE')
> >>>> platform.python_version()
> > '2.7.8'
> >>>> platform.python_implementation()
> > 'CPython'
> > Using WMI-1.4.9.win32 - downloaded via PIP
> > pywin32-219.win-amd64-py2.7
> Just for reference, this is a general Python discussion list. Lots of
> us won't know specific libraries, so all we can offer is fairly
> general information. If you can't get the help you need here, you may
> do better to look for more specific help about this module.
> All the best!
More information about the Python-list