Created
April 14, 2015 20:21
-
-
Save SteveGilham/7706ec7ce6c25809f58d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import clr | |
| clr.AddReference("System.Management") | |
| from System.Management import * | |
| from System import Console | |
| def EvLogEventArrived(sender, e): | |
| ##Get the Event object and display it | |
| for pd in e.NewEvent.Properties: | |
| Console.WriteLine("{0} = {1}", pd.Name, pd.Value) | |
| scope = ManagementScope("root\\default"); | |
| q = WqlEventQuery(); | |
| q.EventClassName = "RegistryValueChangeEvent" | |
| q.Condition = "Hive='HKEY_LOCAL_MACHINE' and KeyPath='Software\\\\RavnaAndTines'"+ | |
| " and ValueName='my key'"; | |
| w = ManagementEventWatcher(scope, q) | |
| try: | |
| w.EventArrived += EventArrivedEventHandler(EvLogEventArrived) | |
| w.Start() | |
| Console.ReadLine() ## Block this thread, keeping the app active | |
| ##and letting the event be handled on a system thread | |
| w.Stop() | |
| finally: | |
| w.Dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment