Example of how to get a list of installed programs (like Add and Remove Programs) - Page 3-VBForums
Page 3 of 3 FirstFirst 123
Results 81 to 101 of 101

Thread: Example of how to get a list of installed programs (like Add and Remove Programs)

  1. #81

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    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.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  2. #82
    New Member
    Join Date
    Feb 2012
    Posts
    1

    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.)
    Last edited by JFoushee; Mar 20th, 2012 at 09:34 AM.

  3. #83

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    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.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #84
    New Member
    Join Date
    Mar 2012
    Posts
    4

    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.


  5. #85
    New Member
    Join Date
    Jul 2012
    Posts
    1

    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

  6. #86

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Example of how to get a list of installed programs (like Add and Remove Programs)

    Quote Originally Posted by Midomoi View Post
    Miss list of update which have a "This update cannot be removed" info type.

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  7. #87

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Example of how to get a list of installed programs (like Add and Remove Programs)

    Quote Originally Posted by WishWell View Post
    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).
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  8. #88
    New Member
    Join Date
    Aug 2012
    Posts
    1

    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:
    Name:  duplicate.png
Views: 1041
Size:  57.5 KB

    Missing:
    Name:  missing.png
Views: 1094
Size:  225.5 KB

    Anyway, Cool app!

  9. #89
    New Member
    Join Date
    Sep 2012
    Posts
    1

    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

  10. #90

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Example of how to get a list of installed programs (like Add and Remove Programs)

    Quote Originally Posted by jmb555 View Post
    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:
    Name:  duplicate.png
Views: 1041
Size:  57.5 KB

    Missing:
    Name:  missing.png
Views: 1094
Size:  225.5 KB

    Anyway, Cool app!
    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  11. #91

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Example of how to get a list of installed programs (like Add and Remove Programs)

    Quote Originally Posted by kitrafael View Post
    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
    Last edited by chris128; Oct 7th, 2012 at 05:15 PM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  12. #92
    New Member
    Join Date
    Nov 2012
    Posts
    8

    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

  13. #93

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  14. #94
    New Member
    Join Date
    Aug 2009
    Location
    ALABAMA
    Posts
    13

    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?

  15. #95
    Registered User
    Join Date
    Jan 2013
    Posts
    2

    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

  16. #96

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,598

    Re: Example of how to get a list of installed programs (like Add and Remove Programs)

    Quote Originally Posted by sachinnpanchal View Post
    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  17. #97
    Registered User
    Join Date
    Jan 2013
    Posts
    2

    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

    InstalledProgram.cs

  18. #98
    New Member
    Join Date
    Mar 2013
    Location
    philippines
    Posts
    5

    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

  19. #99
    Member
    Join Date
    Aug 2011
    Posts
    47

    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!

  20. #100
    New Member
    Join Date
    Jan 2014
    Posts
    2

    Re: Example of how to enumerate installed programs (like Add and Remove Programs)

    Quote Originally Posted by SuperJohn View Post
    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.
    Attached Files Attached Files

  21. #101
    New Member
    Join Date
    Jan 2014
    Posts
    2

    Re: Example of how to enumerate installed programs (like Add and Remove Programs)

    Quote Originally Posted by stefan52a View Post
    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.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.