views:

256

answers:

4

Using C# .NET 2.0 or greater and Visual Studio 2008, how would one generate a list of all installed applications on a Windows Vista PC?

My motivation is to get a text file of all my installed applications that I can save and keep around so that when I rebuild my machine I have a list of all of my old applications.

The second part of this question is kind of SuperUser.com thing, but hopefully the first part counts as "programming".

Thanks

+5  A: 

Hi there.

You could look into referencing the SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall registry key. Check out these links:

http://www.onedotnetway.com/get-a-list-of-installed-applications-using-linq-and-c/ http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/ac23690a-f5f8-46fc-9047-c369f4370fac

Cheers. Jas.

Jason Evans
Of course, this will only return a list of applications that are listed in the registry. Applications deployed via XCOPY deployment won't show up.
pmarflee
Yeah, potentially not all of Adam's apps will appear in the registry, since they could be apps which were copied onto disk rather then installed.
Jason Evans
Thanks. StackOverflow rules!
Adam Kane
Great idea using linq!
Philip Wallace
+1  A: 

See the source code of this library

foreach(var info in BlackFox.Win32.UninstallInformations.Informations.GetInformations())
{
    Console.WriteLine(info.ToString());
}
VirtualBlackFox
A: 

One must also account for different levels of installedness.

  • An app may have had things done to it (deleted, etc.) since it was installed.
  • Some apps don't 'install', but rather run as naked binaries.
tsilb
+2  A: 

The follwing will get you the installed apps for all users. Do the same for Registry.CurrentUser as well:

    RegistryKey uninstall = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
 List<string> applicationList = new List<string>();
 foreach (string subKeyName in uninstall.GetSubKeyNames())
 {
  RegistryKey subKey = uninstall.OpenSubKey(subKeyName);
  string applicationName = subKey.GetValue("DisplayName", String.Empty).ToString();
  if (!String.IsNullOrEmpty(applicationName))
  {
   applicationList.Add(applicationName);
  }
  subKey.Close();
 }

 uninstall.Close();

 applicationList.Sort();

 foreach (string name in applicationList)
 {
  Console.WriteLine(name); 
 }

DISCLAIMER: There is no null value/error checking in my sample!

Philip Wallace