I am trying to get a vbScript to fire off when a particular registry entry
changes using the ActiveScriptEventConsumer.
I have created the instances of __EventFilter, __EventConsumer and
__FilterToConsumerBinding and can see them using CIM studio but nothing
appears to happen when the entry changes.
The event query works as a tempoary subscription, but I need to get it
working as a permanent subscription.
Here's the code I used for creating the classes
Set objSWbemServices = GetObject("winmgmts:root\cimv2")
Set objEventFilterClass = objSWbemServices.Get("__EventFilter")
Set objEventFilter = objEventFilterClass.SpawnInstance_()
objEventFilter.Name = "MonitorVPNStatus"
objEventFilter.QueryLanguage = "WQL"
objEventFilter.Query = _
"SELECT * FROM RegistryValueChangeEvent WITHIN 5 " _
& "WHERE Hive='HKEY_LOCAL_MACHINE' AND " _
& "KeyPath='SOFTWARE\\CheckPoint\\SecuRemote\\Status' " _
& "AND ValueName='ClientConnected'"
objEventFilter.Put_()
Set objConsumerClass = objSWbemServices.Get("ActiveScriptEventConsumer")
Set objConsumer = objConsumerClass.SpawnInstance_()
objConsumer.Name = "VPNScript"
objConsumer.ScriptFileName = "C:\Windows\VPNScript.vbs"
objConsumer.ScriptingEngine = "VBScript"
objConsumer.Put_()
Set objBindingClass = objSWbemServices.Get("__FilterToConsumerBinding")
Set objBindingInstance = objBindingClass.SpawnInstance_()
objBindingInstance.Filter = "MonitorVPNStatus"
objBindingInstance.Consumer = "VPNScript"
objBindingInstance.Put_()
Any help would be most greatly appreciated