-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Yeah that's fine and certainly secure, I just think it would be really useful with an app like that to be able to tell it to launch a custom action (e.g a script or executable) so that you don't have to recompile and redeploy the app whenever you want it to do something that it doesn't already do.
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
This code is great!... but with Server 2008 onward, Microsoft has changed the way the OS reports Installed Updates.
After some research, I'm able to get the non-OS Installed Updates (MS Office hotfixes, SQL Server Service Packs) using this code:
(This goes inside Private Shared Function InternalGetInstalledPrograms, between the lines "Next" and "'Close the registry keys")
Code:
'-- Windows 2008 - JFoushee (2/2012)
Dim key As RegistryKey = HklmPath.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion\")
Dim strTemp As String = key.GetValue("CurrentVersion").ToString()
If IsNumeric(strTemp) Then
Dim dblReturn As Double = Convert.ToDouble(strTemp)
If dblReturn >= 6.0 Then
'-- Windows 2008 non-QFE Patches
Dim Win2K8PatchKey As RegistryKey = HklmPath.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products")
ProgramList = Get2008NonQFEPatches(Win2K8PatchKey, HklmPath, ProgramList)
'not sure how to get QFEs by Registry
End If
End If
and this is a new function to go in the "Private Methods" region:
Code:
Private Shared Function Get2008NonQFEPatches(ByVal SystemKey As RegistryKey, ByVal HklmRootKey As RegistryKey, ByVal ExistingProgramList As List(Of InstalledProgram)) As List(Of InstalledProgram)
' addition provided by JFoushee (2/2012). No warranties/guarantees.
If Not SystemKey Is Nothing Then
Dim LmProductGuids() As String = SystemKey.GetSubKeyNames
For Each LmProductGuid As String In LmProductGuids
Dim InstallPropKey As RegistryKey = HklmRootKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" & LmProductGuid & "\InstallProperties")
If InstallPropKey IsNot Nothing Then
If Not CInt(InstallPropKey.GetValue("SystemComponent", 0)) = 1 Then
Dim ParentName As String = CStr(InstallPropKey.GetValue("DisplayName", String.Empty))
Dim Vendor As String = CStr(InstallPropKey.GetValue("Publisher", String.Empty))
Dim PatchesKey As RegistryKey = HklmRootKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" & LmProductGuid & "\Patches")
If PatchesKey IsNot Nothing Then
Dim LmPatchGuids() As String = PatchesKey.GetSubKeyNames
For Each LmPatchGuid As String In LmPatchGuids
If Not CInt(PatchesKey.OpenSubKey(LmPatchGuid).GetValue("State", 1)) = 2 Then
Dim Name As String = CStr(PatchesKey.OpenSubKey(LmPatchGuid).GetValue("DisplayName", String.Empty))
Dim InstallDate As String = ""
Try
InstallDate = CStr(PatchesKey.OpenSubKey(LmPatchGuid).GetValue("Installed", String.Empty))
Catch ex As Exception
End Try
If Not Name = String.Empty AndAlso Not IsProgramInList(Name, ExistingProgramList) Then
ExistingProgramList.Add(New InstalledProgram(Name, ParentName, True, "1", Vendor, "", "", InstallDate))
End If
End If
Next
End If
End If
End If
Next
End If
Return ExistingProgramList
End Function
Now, if someone could figure out the Windows 2008 OS-level hotfixes from the Registry...
(Yes, I 'could' use WMI's Win32_QuickFixEngineering... but then I have two security points-of-failure if someone blocked WMI access.)
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Cool thanks for the additions - I never spent much time on getting the updates (as mentioned in the original post) so even on XP it wasn't giving the correct results for that, as I was only ever really bothered about getting the installed programs rather than installed updates.
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Miss list of update which have a "This update cannot be removed" info type.
http://img824.imageshack.us/img824/6...edprograms.jpg
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Is there a way to get more information about each product such as the publisher(or vendor) and installed location
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Quote:
Originally Posted by
Midomoi
Yeah like I said, I didn't spend much time on getting the update detection to work properly cos I was only interested in programs not updates
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Quote:
Originally Posted by
WishWell
Is there a way to get more information about each product such as the publisher(or vendor) and installed location
Yep, and I think someone else already asked in this thread about it. Just look at the source code and find the places where it is getting values like UninstallString, Version, SystemComponent etc etc from the registry and in there you need to get the Vendor value (or whatever its called, look in your own registry to find out).
-
2 Attachment(s)
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Hi!
I'm trying this one to check for OS Hotfixes(updates) that are installed on my machine. I found out that there are some missing updates and duplicate entry.
Duplicate:
Attachment 90495
Missing:
Attachment 90497
Anyway, Cool app! :D
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Hi Chris128,
Firstly, this app is really awesome! It helps me a lot when i need to trace what apps was installed in the labs.
I have questions here, still using the 'UserDataKeyName' and im interested to populated the 'publisher' of all apps installed and how could we do so? if possible, i need to flag with a check box like what you did for 'include updates' and 'only show updates'.. then the 'publisher' data will shown in the Forms.ListView
Can you help with this?
Hope to hear from you soon.
Thanks!
kitrafael
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Quote:
Originally Posted by
jmb555
Hi!
I'm trying this one to check for OS Hotfixes(updates) that are installed on my machine. I found out that there are some missing updates and duplicate entry.
Duplicate:
Attachment 90495
Missing:
Attachment 90497
Anyway, Cool app! :D
Yeah like I've said before, I didn't really ever concentrate on the update side of things as I only ever wanted the list of programs (not updates) - that was just a bonus really because it looked like it was fairly easy to do, but evidently its not working quite right. If you want it to reliably get all of the updates installed then you'd have to look at the code and see where it is going wrong and why it is picking up duplicates
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Quote:
Originally Posted by
kitrafael
Hi Chris128,
Firstly, this app is really awesome! It helps me a lot when i need to trace what apps was installed in the labs.
I have questions here, still using the 'UserDataKeyName' and im interested to populated the 'publisher' of all apps installed and how could we do so? if possible, i need to flag with a check box like what you did for 'include updates' and 'only show updates'.. then the 'publisher' data will shown in the Forms.ListView
Can you help with this?
Hope to hear from you soon.
Thanks!
kitrafael
Like I've said before in this thread, if you want to get the publisher then just change the code so that as well as reading the DisplayName and Version registry values it also reads and stores the Publisher value. If you follow the code through its fairly obvious where it is actually reading and storing the display name and version values so just add another line in there to grab the publisher value.
EDIT: wow over 5000 downloads of this library now (and not many complaints). Hope it is helping people out :)
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
1st thanks a bunch chris128 its a great program. Thanks again. I have a question is it possible if I want to know 2-3 specific program such as microsoft office is it intalled or not , adobe pdf is installed or not?
If so can you please provide sample code ?
Best regards
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Just loop through the list that my code gives you and check to see if it contains the program you are looking for. I'm not going to show you how to loop through a list, because that's very basic programming and if you're unsure how to do things like that then you should go through a few beginners tutorials
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Now is there a way to remove programs from this? I wonder how you could do that?
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Hi Chris,
I looked into your example and working like exactly like Windows (I would say more better then windows because windows sometimes duplicates programs whereas your program didn't).
But I have one problem, code is in VB.Net. I like to do same thing in c#. but when I convert your code from vb.net to c# (using online conversion tool) it gives wrong output in c# version. I compared both code it is same way written in c#. but although don't know why it is not correctly working. It would be great if you can upload C# version.
I can't you DLL of your code (I gives prefect in c# if I use VB.Net dll). I need that class to be in c#.
Any help appreciated.
Regards,
Sachin
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Quote:
Originally Posted by
sachinnpanchal
Hi Chris,
I looked into your example and working like exactly like Windows (I would say more better then windows because windows sometimes duplicates programs whereas your program didn't).
But I have one problem, code is in VB.Net. I like to do same thing in c#. but when I convert your code from vb.net to c# (using online conversion tool) it gives wrong output in c# version. I compared both code it is same way written in c#. but although don't know why it is not correctly working. It would be great if you can upload C# version.
I can't you DLL of your code (I gives prefect in c# if I use VB.Net dll). I need that class to be in c#.
Any help appreciated.
Regards,
Sachin
Sorry I don't really know C# at all so can't help you. You'd probably be better off asking on a C# forum than a VB forum ;)
-
1 Attachment(s)
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Hi Chris,
I resolved problem in C# code. it was a problem in reverse function. If any one wants see please download attachment.
One more thing chris, I want to develop one small utility to find out problems in Registry like (CCleaner). Do you any idea for this kind of thing?
Any help would be appreciated.
Regards,
Sachin
Attachment 95871
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
sir,need help for our thesis pruposal, we need to scan installed software from a network in just one clicking the scan button,,
can u help us? we cant find codes, we search night and day but we got lost:(
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Thanks for the code, it is very helpful.
I understand that it takes information from the registry, which only contains program name. But is there any possible way to get also the executable path? Thanks!
-
1 Attachment(s)
Re: Example of how to enumerate installed programs (like Add and Remove Programs)
Quote:
Originally Posted by
SuperJohn
can u use this to uninstall programs? like in xp when you double click the program?
icons would be cool too
Just to say thanks for the code, I am not a vb wizard, but changed the test program a bit to include the uninstal strings, and added a sample program to uninstall 1 program based upon its display name.
-
Re: Example of how to enumerate installed programs (like Add and Remove Programs)
Quote:
Originally Posted by
stefan52a
Just to say thanks for the code, I am not a vb wizard, but changed the test program a bit to include the uninstal strings, and added a sample program to uninstall 1 program based upon its display name.
O yeah, forgot to tell works fine in windows 8.1 as well, but have to run as administrator.
-
Re: Example of how to get a list of installed programs (like Add and Remove Programs)
Wow, this is fast and works in Windows 10 if you Run As administrator. Unfortunately, for about 25% of my programs, it doesn't return the version number even though I can see the version number in the normal Apps & Features program list.
The values can be found in
Code:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
and I recommend retrieving them from there. I checked and, in all cases where it was missing from what your program showed me, the version information could be found in the above registry section.