Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi All,

I want to run a specific installed program from my list.

I have the name of the program but not the installed path of it.

I also have a list which contains all the installed programs on my computer.

Is there any way to run a program directly from that list?

I have used following code to get list of installed programs.
C#
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
 foreach (string skName in rk.GetSubKeyNames())
 {
 using (RegistryKey sk = rk.OpenSubKey(skName))      
{                                               
 if (!(sk.GetValue("DisplayName") == null))
  {  lstProgramList.Add(sk.GetValue("DisplayName").ToString());
  }
  }
 }
 }
Posted
Updated 15-Nov-11 23:25pm
v4
Comments
Mark Salsbery 16-Nov-11 11:21am    
This has absolutely nothing to do with WPF. If you add more topic categories to your post you may get better response.
Sergey Alexandrovich Kryukov 16-Nov-11 12:22pm    
What is this: "I have the name of the program but not the installed path of it."?
--SA
Sergey Alexandrovich Kryukov 16-Nov-11 12:24pm    
"Is there any way to run a program directly from that list?"
What is "directly" and what is "indirectly"?
--SA

1 solution

OK, you can do it by enumerating throw the installing program list and in inner loop trying to find its DisplayName in your "name list". Instead of list you can use System.Collections.Generic.Dictionary for fast search.

However, there is no reliable way to identify a program based on this name. The name does not uniquely identify the program, so two programs can have the same name, in principle. Nobody cares about it because it is hardly required. I have no idea why do you require such thing. It smells poor architecture to me, no more…

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900