The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RegistryTreeChangeEvent class

The RegistryTreeChangeEvent class represents changes to a key and its subkeys. For more information about using the WMI registry event classes, see the Modifying the System Registry section. For code examples, see the WMI Tasks: Registry topic.

The following syntax is simplified from Managed Object Format (MOF) code and includes all inherited properties. Properties and methods are in alphabetic order, not MOF order.


class RegistryTreeChangeEvent :  RegistryEvent
  string Hive;
  string RootPath;
  uint64 TIME_CREATED;


The RegistryTreeChangeEvent class has these types of members:


The RegistryTreeChangeEvent class has these properties.

Data type: string
Access type: Read-only

Name of the hive that contains the key (or keys) that is changed. For example, HKEY_LOCAL_MACHINE. Changes to the HKEY_CLASSES_ROOT and HKEY_CURRENT_USER hives are not supported by RegistryEvent or classes derived from it, such as RegistryTreeChangeEvent.

Data type: string
Access type: Read/write

Path to the registry key that contains the subkeys. For example, "SOFTWARE\Microsoft".

Data type: uint8 array
Access type: Read-only

Descriptor that the event provider uses to determine which users can receive an event. This property is inherited from __Event. A NULL access control list (ACL) in the SECURITY_DESCRIPTOR grants unlimited access to everyone all the time. For more information, see Creating a Security Descriptor for a New Object.

Data type: uint64
Access type: Read-only

Unique value that indicates the time when an event is generated. This is a 64-bit FILETIME value that represents the number of 100-nanosecond intervals after January 1, 1601. The information is in the Coordinated Universal Time (UTC) format. This property is inherited from __Event. To convert this value to other time formats, use the SWbemDateTime methods SetFileTime and GetFileTime. For more information, see WMI Tasks: Dates and Times.

For more information about using uint64 values in scripts, see Scripting in WMI.


Queries that provide a RootPath must have backslashes escaped. For example,

    & "SELECT * FROM RegistryTreeChangeEvent " _
    & "RootPath='SOFTWARE\\Microsoft'")

Registry provider classes, unlike most of the Win32 classes are located in the WMI root\default namespace.


The following example waits for changes in the HKEY_LOCAL_MACHINE hive using semisynchronous access. It runs until the Wscript.exe process is stopped in Task Manager. The 64-bit TIME_CREATED property is converted to a printable date by SWbemDateTime methods. For more information, see Calling a Method.

The following script runs until the computer is restarted, WMI is stopped, or the script is stopped. To stop the script manually, use Task Manager to stop the process. To stop it programmatically, use the Terminate method in the Win32_Process class.

wbemFlagReturnImmediately = 16
wbemFlagForwardOnly = 32
IFlags = wbemFlagReturnImmediately + wbemFlagForwardOnly

Set wmiServices = GetObject("winmgmts:root/default") 
Set dtmCreateTime = CreateObject("WbemScripting.SWbemDateTime")

Set colRegChanges = wmiServices.ExecNotificationQuery _
    ("SELECT * FROM RegistryTreeChangeEvent " _
    & "WHERE Hive='HKEY_LOCAL_MACHINE' AND RootPath=''",, IFlags)

Do While (True)
   Set TreeChange = colRegChanges.NextEvent

'Time_Created property is 64-bit and
' must be converted into CIM_DateTime format
   dtmCreateTime.SetFileTime TreeChange.Time_Created, false

'Convert to VT_DATE format using GetVarDate
' for printing to screen
   Wscript.Echo "Time = " & dtmCreateTime.GetVarDate() _
              & VBNewLine _
              & "Hive = " & TreeChange.Hive & VBNewLine _
              & "RootPath = "& TreeChange.RootPath    


Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003







See also

Registering for System Registry Events



© 2014 Microsoft