0

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 ?

mmk_open
  • 1,005
  • 5
  • 18
  • 27
  • possible duplicate of [How to get a list of installed software products?](http://stackoverflow.com/questions/3526449/how-to-get-a-list-of-installed-software-products) – Cody Gray - on strike May 26 '11 at 10:33
  • Given this and [your last question](http://stackoverflow.com/questions/6136763/c-net-operating-system-installed-directory), I get the sense you're about to embark down a really bad path doing all sorts of things that you shouldn't be doing in ways that you shouldn't be doing them. – Cody Gray - on strike May 26 '11 at 10:37

1 Answers1

1

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;
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263