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 *How I am doing it: * import wmi import _winreg 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") while True: try: process_created = watcher() print 'value changed' Event is caught perfectly but *Problem: * 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__ handle_com_error () 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. """ try: event = self.wmi_event.NextEvent (timeout_ms) if self.is_extrinsic: return _wmi_event (event, None, self.fields) else: return _wmi_event ( *event.Properties_ ("TargetInstance").*Value, _wmi_object (event, property_map=self._event_property_map), self.fields ) except pywintypes.com_error: handle_com_error () *self.is_extrinsic returns false and event.Properties_("TargetInstance").Value throws the exception* Is there a way I can explicitly initialize the class _wmi_watcher and set self.is_extrinsic = True? 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 Thanks khyati
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32