![]() |
Finding all installed programs from the registry |
Post Reply
|
Page 12> |
| Author | |
Chris128
Groupie
Joined: 14 August 2009 Location: England Status: Offline Points: 75 |
Post Options
Thanks(1)
Quote Reply
Topic: Finding all installed programs from the registryPosted: 04 December 2009 at 9:01pm |
|
Hi Guys,
Basically I am writing a vb.net program that finds all installed programs on a PC, exactly like Add/Remove Programs does.
So I thought all I would need to do is loop through the keys in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall and that would be it... unfortunately not, that only gets about half of the programs installed on my PC. From using Process Monitor to watch which registry keys Add/Remove Programs accesses, I have found that I need to look at several other keys as well.... and after playing around with this for a while I have got it to work pretty much exactly like Add/Remove Programs but it still has the odd problem where it will get say 1 more program than Add/Remove Programs does. On my Windows 7 PC my code always picks up Microsoft Choice Guard as a program, where as Add/Remove Programs does not show it. On my Windows XP test machine it picks up just one random Windows Update, which obviously Add/Remove Programs does not show unless you have the Show Updates thing ticked. I have got my code to check the ReleaseType value in each key to see if it is "Hotfix", "Update Rollup", "Service Pack" etc but the window update my program is showing does not have the ReleaseType value at all anyway :( So basically, I'm just wondering if there is anyone out there with a good understanding of how add/remove programs does its thing that might be able to help me out a bit?
If you want to see my VB.NET code then let me know but here is the basic logic of my program:
1. Loop through all subkeys in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
2. For each subkey, do the following:
--Check to see if the SystemComponent value exists and is set to 1 - if it is then move on to the next subkey
--Check to see if the WindowsInstaller value exists and is set to 1 - if it is then move on to next subkey
--Check to see if the UninstallString value exists - if it does not then move on to next subkey
--Check the ReleaseType value, if it is hotix or service pack etc then move on to next subkey
--Check the ParentKeyName value, if it exists then move on to next subkey
--Check to see if the DisplayName value exists - if it does then add this name to our list of installed programs
3. Repeat this same process for all subkeys in HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall if it exists.
4. Loop through all users in HKEY_USERS and for each one, loop through the subkeys in HKU\USER-SID-HERE\Software\Microsoft\Windows\CurrentVersion\Uninstall and do the exact same thing described in step 2
5. Whilst looping through all users in HKEY_USERS, also check HKU\USER-SID-HERE\Software\Microsoft\Installer\Products and for each subkey in there do the following:
--Check to see if a subkey with the same GUID name exists in HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\USER-SID-HERE\Products - if it does then check to see if the SystemComponent value in the InstallProperties subkey is set to 1 - if it is then move on to the next subkey
--Read the ProductName value and add it to our list of installed programs
6. Loop through all subkeys in HKLM\Software\Classes\Installer\Products and for each one do the following:
--Check to see if a subkey with the same GUID name exists in HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products - if it doesnt then move on to the next subkey
--Check the SystemComponent value is not set to 1 - if it is set to 1 then move on to next subkey
--Check the WindowsInstaller value exists and is set to 1 - if it is not then move to next subkey
--Read the ProductName value and add it to our list of installed programs
THE END
Anyone see anything I am missing or doing wrong? Like I said, this works fairly well but just seems to show one or two programs that Add/Remove Programs does not for some reason...
One thing I am also particularly struggling with is how Windows determines whether an installed program is an update or not. If it has the ReleaseType value or ParentKeyName set then its easy to tell but if not then I dont understand how it knows its not just another normal program..
Thanks!
Chris
|
|
![]() |
|
Chris128
Groupie
Joined: 14 August 2009 Location: England Status: Offline Points: 75 |
Post Options
Thanks(0)
Quote Reply
Posted: 04 December 2009 at 10:14pm |
I could still do with some help on why Microsoft Choice Guard shows up in my program but not in Add/Remove though :) Edited by Chris128 - 04 December 2009 at 10:15pm |
|
![]() |
|
Chris128
Groupie
Joined: 14 August 2009 Location: England Status: Offline Points: 75 |
Post Options
Thanks(0)
Quote Reply
Posted: 05 December 2009 at 3:59am |
|
OK I've narrowed it down a little more... In the following key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{XXXXX-XXXXXX-XXXXX} (Where XXXX-XXXX is the GUID name of the installer package) I found the one for Choice Guard and noticed that inside it there was the SystemComponent flag set, so I deleted that value and it then showed up in Add/Remove Programs. So my code obviously needs to check to see if this flag exists... the problem is that it already does this! However, what my code does is just ignores that entry in the Uninstall subkey if the SystemComponent flag is set - what Windows seems to do is ignore that entry in the Uninstall subkey and any entries for that same product in HKLM\Software\Classes\Installer\Products . What I cant understand though is how it links these 2 things together, because the GUID name used in the first key I mentioned is not the same as the Hex/Guid/whatever name that the same product has in the second location. The only thing that is the same is the display name and I'm sure it cant go on that because there are some other products in both locations that have the same name in both and have SystemComponent set in one, yet the product still appears in Add/Remove Programs. I also just noticed that if I delete the SystemComponent flag for one of the other programs that already appears in Add/Remove Programs it then appears in there twice... even though for another program that appears in Add/Remove Programs it already does not have the SystemComponent flag anyway |
|
![]() |
|
Bruce9
Groupie
Joined: 30 May 2008 Status: Offline Points: 47 |
Post Options
Thanks(0)
Quote Reply
Posted: 07 December 2009 at 2:08pm |
|
See "Add/Remove Programs " source code.
(posted on Win32 group http://tinyurl.com/yjy3ajr , uses COM, C++ code)
|
|
![]() |
|
Chris128
Groupie
Joined: 14 August 2009 Location: England Status: Offline Points: 75 |
Post Options
Thanks(0)
Quote Reply
Posted: 07 December 2009 at 2:25pm |
|
Sorry but that link you posted doesnt seem to contain any relevant information. I searched for Add/Remove Programs , Add Remove Programs , Add Remove Programs Source Code and various other things and it didnt find anything useful
|
|
![]() |
|
nullptr
Senior Member
Joined: 06 April 2008 Location: Australia Status: Offline Points: 746 |
Post Options
Thanks(0)
Quote Reply
Posted: 07 December 2009 at 2:55pm |
|
Try searching: list installed programs
|
|
![]() |
|
Chris128
Groupie
Joined: 14 August 2009 Location: England Status: Offline Points: 75 |
Post Options
Thanks(0)
Quote Reply
Posted: 17 December 2009 at 9:03pm |
|
Thanks I found the references to IShellAppManager and IEnumInstalledApps but it seems that there is very little on the internet about these two items (cant remember the last time I did a google search and only got one page of results!) so I dont even know where those APIs are defined, so I cant begin to try and call them from my .NET application :(
|
|
![]() |
|
Chris128
Groupie
Joined: 14 August 2009 Location: England Status: Offline Points: 75 |
Post Options
Thanks(0)
Quote Reply
Posted: 15 January 2010 at 7:50pm |
|
Just for anyone interested, I have pretty much finished this program now and it works quite well - on every PC I have tested the latest version on it has detected exactly the same programs that Add/Remove Programs detected (apart from Windows Updates or anything that is only displayed when you tick the Include Updates box in Add/Remove programs, as I am not bothered about detecting them really). I didnt end up using the Windows APIs mentioned and just did it all myself by looking up various registry keys. I figured out how to convert the GUID name shown in the Uninstall key to a windows installer ID - if you split the original GUID string up into 2 halfs after the second hyphen, in the first half each block is just reversed and in the second section characters are reversed in groups of 2. Here's an example:� Original String: Its probably easier to see what I mean if I display the strings like this: Original String: Anyway, once I had figured that out, I just basically made my app loop through the Uninstall key and for each item, if the WindowsInstaller flag is set, then it converts the GUID name of the current key (as explained above) and then looks in Classes\Installer\Products for that converted string as the name of one of the subkeys. If it finds it then it pulls information from that subkey. Obviously there is a bit more to it than that but if anyone wants to see exactly how my code works the full source code (and an example application that uses it) is here: http://cjwdev.wordpress.com/2010/01/06/enumerate-installed-programs/ Cheers, Chris Edited by Chris128 - 12 April 2010 at 2:30pm |
|
![]() |
|
hwee
Newbie
Joined: 08 February 2011 Location: US Status: Offline Points: 1 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 February 2011 at 7:20pm |
|
Hi Christ, I tried your program and it worked great. However, i was wondering that we can display the GUID (key) of each installed software. By the way, I was trying to findout the GUID of the the McAfee that is install on the PC. If you have a minute, could you give me some suggestions? Thanks |
|
|
HHH
|
|
![]() |
|
Drewfus
Groupie
Joined: 12 February 2010 Status: Offline Points: 44 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 February 2011 at 10:55pm |
![]() |
|
Post Reply
|
Page 12> |
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |