strComputer = "."
Set objWMIServices = GetObject("winmgmts:root/default")
Set wmiSink = WScript.CreateObject("WbemScripting.SWbemSink", "SINK_")
Set ObjRegistry = GetObject("winmgmts:{impersonationLevel = impersonate}!\" _
& strComputer & "rootdefault:StdRegProv")
objWMIServices.ExecNotificationQueryAsync wmiSink, _
"SELECT * FROM RegistryKeyChangeEvent " _
& "WHERE Hive='HKEY_LOCAL_MACHINE' AND " _
& "KeyPath='Software\Microsoft\Windows\CurrentVersion\Uninstall'"
WScript.Echo "Listening for Registry Change Events..."
While(True)
WScript.Sleep 1000
Wend
Sub SINK_OnObjectReady(EventObject, wmiAsyncContext)
WScript.Echo "Received Registry Change Event" & vbCrLf & _
EventObject.GetObjectText_()
End Sub
The following is a WMI code that looks for the 'Uninstall.exe' of any installed software. I am attempting to put this code into a Windows Service for my school project. But when I tested using Cscript, no result was found. I need major help.
Also, if possible, I'd like it to be converted to a VB Console Application. I know how, but one piece of coding for some reason can't converted:
Set wmiSink = WScript.CreateObject("WbemScripting.SWbemSink", "SINK_")
It throws a 'Remote Server cannot be found' exception.
Please help!
Software/Hardware used:
Visual Studio 2008