Reputation: 1035
If I install a software named 'ABC', how could I get the complete installed path in C#.Net if I provide the software name 'ABC' as input ?
Upvotes: 0
Views: 1453
Reputation: 176916
you can try below
using System.Management;
ManagementObjectSearcher MyWMIQuery = new ManagementObjectSearcher("SELECT * FROM Win32_Product") ;
ManagementObjectCollection MyWMIQueryCollection = MyWMIQuery.Get();
foreach(ManagementObject MyMO in MyWMIQueryCollection)
{
if(MyMO["Name"].ToString()=="ABC")
Console.WriteLine("InstallLocation : " + (MyMO["InstallLocation"] == null ? " " : MyMO["InstallLocation"].ToString()));
Console.ReadLine();
}
MyWMIQueryCollection = null;
MyWMIQuery = null;
Upvotes: 1