querying registry using wmi query in windows

Unnikuttan Kaveth picture Unnikuttan Kaveth · May 23, 2014 · Viewed 13.8k times · Source

I need to get installed software in as shows in Uninstall Program in control panel. So i used Win32_RegistryAction class for querying in vb script. But still i could not query a particular key and it hangs. Here is the piece of code which i used. Please help me how to get installed software details using wmi query.
Thanks in advance

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_RegistryAction where key ='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\' and Root=2 ")

For Each objComputer in colSettings 
Wscript.Echo "Display Name: " & objComputer.DisplayName    
Next

Answer

RRUZ picture RRUZ · May 23, 2014

You are using the wrong WMI class, you must use the StdRegProv class instead, for examples about how use this try the MSDN documentation (WMI Tasks: Registry).