Hi Chip,
Since you had found it out before, this works and anyone can try it,
just place your own path into it. The links are for WMI and probably could
be used for any external app as well. Since async does all the work, you
have to do your own using a timer since all of it is syncronous.
I think there may be some permission, variable, that is not being called
inside the WE connectevent that is needed for Windows 7.
This is the path to the Uninstall folder only and any changes there are
picked up immediately. Even though I check every 3 seconds for the purpose
of not waiting to long for someone to be alerted, it works perfectly.
Finding the example inside of MSDN is a royal pain! And that is no
exageration.
So, after walking my dog I will palce it inside my Uninstall app and
test it. Maybe tonight I will have the next revision level uploaded if it
works for both XP and Windows 7. Those with Vista would have to test it for
me.
' The semi syncronous call:
Dim wmiSemiServices, colTreeChanges ' col = collection
Set wmiSemiServices = GetObject("winmgmts:root/default")
Set colTreeChanges = wmiSemiServices.ExecNotificationQuery _
("SELECT * FROM RegistryTreeChangeEvent " _
& "WHERE Hive='HKEY_LOCAL_MACHINE' " _
& "AND
RootPath='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall'")
Dim TreeChangeTimer: TreeChangeTimer = 0
' Now set the timer for 10 seconds upon start up!
TreeChangeTimer = StartTimer(10000, "QueueTreeChangeTimer")
Sub QueueTreeChangeTimer()
Dim TreeChange
Set TreeChange = colTreeChanges.NextEvent
If Not TreeChange Is Nothing Then
TreeChange.GetObjectText_()
' This msgBox is not needed but does give you any info you desired by
adding more of the properties and methods.
msgBox " The semi syncromous call: " & VBNewLine _
& "Hive = " & TreeChange.Hive & VBNewLine _
& "RootPath = "& TreeChange.RootPath _
& TreeChange.GetObjectText_()
End If
If TreeChangeTimer > 0 Then
StopTimer TreeChangeTimer
TreeChangeTimer = 0
End If
' Now set the timer for 3 seconds each time called!
TreeChangeTimer = StartTimer(3000, "QueueTreeChangeTimer")
End Sub
Bruce,
I remember reading now that some of the event call-backs from Excel also
don't work with WE; that is, just as you're finding WMI isn't able to call a
WE VBScript routine, I seem to recall that some of the Excell events can't
do so either. I suspect you've hit on the same interface issue that the
Excel events are running into (if it's not just the authentication level).
I don't know, but since you have a working alternative, I'd be happy if I
were you; there was no alternative for use of the Excel events with WE.
They will probably be fixed some day, but there's always so much more which
needs attention.
Chip