Enumerating list of applications installed using .NET
I use the following code to enumerate applications installed in my system:
ManagementObjectSearcher mos = new
ManagementObjectSearcher("SELECT * FROM Win32_Product");
ManagementObjectCollection collection = mos.Get();
List<string> appList = new List<string>();
foreach (ManagementObject mo in collection)
{
try
{
string appName = mo["Name"].ToString();
appList.Add(appName);
}
catch (Exception ex)
{
}
}
When I use this code in console or a WPF application, I get the exact list
of apps. But when I use it in a windows service, I'm not getting the
entire list. In my case its 1 application less. Is there a limitation to
use this in Windows Service?
No comments:
Post a Comment