mmk_open
mmk_open

Reputation: 1035

get path of an installed software c#.net

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

Answers (1)

Pranay Rana
Pranay Rana

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

Related Questions