Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Check if software is installed

Check if software is installed

Scheduled Pinned Locked Moved C#
c++questioncsharp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Peter Nirschl
    wrote on last edited by
    #1

    Hello! I want to check if a program is installed. For instance I want to see if the Visual C++ Toolkit 2003 is installed on my computer. How can I do this in C#? Thank you for helping me! :)

    H 1 Reply Last reply
    0
    • P Peter Nirschl

      Hello! I want to check if a program is installed. For instance I want to see if the Visual C++ Toolkit 2003 is installed on my computer. How can I do this in C#? Thank you for helping me! :)

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      There's no complete way of doing this, other than enumerating the registry keys under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall. You can use the System.Management classes to enumerate the Win32_Product CIMv2 class, but that only covers Windows Installer packages. Most of Microsoft's products, samples, etc. use Windows Installer (in fact, I haven't seen one in years besides the Managed DirectX runtime that doesn't - even the .NET Framework uses Windows Installer). For more information and a great add-in for VS.NET 2002 and VS.NET 2003, read WMI and .NET: System.Management Lets You Take Advantage of WMI APIs within Managed Code -- MSDN Magazine, May 2002[^]. For links to the add-ins, see http://www.microsoft.com/downloads/results.aspx?productID=BF0EBDD7-5D74-479A-B01E-D7B141200243&freetext=WMI&DisplayLang=en[^].

      Microsoft MVP, Visual C# My Articles

      W 1 Reply Last reply
      0
      • H Heath Stewart

        There's no complete way of doing this, other than enumerating the registry keys under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall. You can use the System.Management classes to enumerate the Win32_Product CIMv2 class, but that only covers Windows Installer packages. Most of Microsoft's products, samples, etc. use Windows Installer (in fact, I haven't seen one in years besides the Managed DirectX runtime that doesn't - even the .NET Framework uses Windows Installer). For more information and a great add-in for VS.NET 2002 and VS.NET 2003, read WMI and .NET: System.Management Lets You Take Advantage of WMI APIs within Managed Code -- MSDN Magazine, May 2002[^]. For links to the add-ins, see http://www.microsoft.com/downloads/results.aspx?productID=BF0EBDD7-5D74-479A-B01E-D7B141200243&freetext=WMI&DisplayLang=en[^].

        Microsoft MVP, Visual C# My Articles

        W Offline
        W Offline
        Wackatronic
        wrote on last edited by
        #3

        Even after enumerating and possibly finsing the correct registry key, you should check for the exsistence of the dll or exe. Windows applications are infamous for not removing all registry entries after an un-install or even people will delete directories without using the un-install. Top and bottom is even if it has a registry key, don't assume that it's there. Just expanding on what Heath mentioned. Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!

        Visit my Code Project blog (Mobile Audio project)[^]

        H 1 Reply Last reply
        0
        • W Wackatronic

          Even after enumerating and possibly finsing the correct registry key, you should check for the exsistence of the dll or exe. Windows applications are infamous for not removing all registry entries after an un-install or even people will delete directories without using the un-install. Top and bottom is even if it has a registry key, don't assume that it's there. Just expanding on what Heath mentioned. Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!

          Visit my Code Project blog (Mobile Audio project)[^]

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          True to a point (although he didn't ask about files - merely products), but Windows Installer - unless you explicitly change the execution sequence from the default or change the Component table attributes or transitive condition to keep the component installed during uninstall - will remove all files it placed there originally. Windows Installer really is a powerful package distribution system, something I've been working with since it's 1.0 beta days and am currently beta testing for 3.0. If you're interested, you should take a look at the Windows Installer SDK on MSDN.

          Microsoft MVP, Visual C# My Articles

          W 1 Reply Last reply
          0
          • H Heath Stewart

            True to a point (although he didn't ask about files - merely products), but Windows Installer - unless you explicitly change the execution sequence from the default or change the Component table attributes or transitive condition to keep the component installed during uninstall - will remove all files it placed there originally. Windows Installer really is a powerful package distribution system, something I've been working with since it's 1.0 beta days and am currently beta testing for 3.0. If you're interested, you should take a look at the Windows Installer SDK on MSDN.

            Microsoft MVP, Visual C# My Articles

            W Offline
            W Offline
            Wackatronic
            wrote on last edited by
            #5

            [original posting]I want to check if a program is installed. For instance I want to see if the Visual C++ Toolkit 2003 is installed on my computer. How can I do this in C#? The point I'm refering to is that just because something has a registry entry, doesn't mean it exists, only that it was installed at some point in time. I know from experience not to take anything for granted if it has a registry entry. Heath Stewart wrote: (although he didn't ask about files - merely products), He wants to see if a specific product is installed. I merely wanted to point out that an un-install may have failed or been un-installed incorrectly (like deleting directory - infamous in users :) ) and still have left registry entries that may be included in the enum. Regards, Eric C. Tomlinson P.S. Haven't used Windows Installer yet, all the clients I work for have subjected me to Installshield X| Maybe someday I'll be able to use it on something that I write (and actually finish) ;P Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!

            Visit my Code Project blog (Mobile Audio project)[^]

            H 1 Reply Last reply
            0
            • W Wackatronic

              [original posting]I want to check if a program is installed. For instance I want to see if the Visual C++ Toolkit 2003 is installed on my computer. How can I do this in C#? The point I'm refering to is that just because something has a registry entry, doesn't mean it exists, only that it was installed at some point in time. I know from experience not to take anything for granted if it has a registry entry. Heath Stewart wrote: (although he didn't ask about files - merely products), He wants to see if a specific product is installed. I merely wanted to point out that an un-install may have failed or been un-installed incorrectly (like deleting directory - infamous in users :) ) and still have left registry entries that may be included in the enum. Regards, Eric C. Tomlinson P.S. Haven't used Windows Installer yet, all the clients I work for have subjected me to Installshield X| Maybe someday I'll be able to use it on something that I write (and actually finish) ;P Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!

              Visit my Code Project blog (Mobile Audio project)[^]

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              I know that non-Windows Installer products are notorious for this, but Window Installer packages are actually transacted - you won't see this behavior (except, perhaps, from poorly-written custom actions where the developer doesn't take rollbacks into account or simply can't). It's Windows Installer I'm defending, not installs. Regarding installs in general, I wholy agree with you...except for one problem: proprietary installs are just that - proprietary. There may be no way to determine where to even look for a product if the install information (or, rather, the uninstall information) doesn't tell you. This is another reason why Windows Installer kicks butt: it's a relational database and tracks everything from files, registry entries, and feature and component installation states. :)

              Microsoft MVP, Visual C# My Articles

              P 1 Reply Last reply
              0
              • H Heath Stewart

                I know that non-Windows Installer products are notorious for this, but Window Installer packages are actually transacted - you won't see this behavior (except, perhaps, from poorly-written custom actions where the developer doesn't take rollbacks into account or simply can't). It's Windows Installer I'm defending, not installs. Regarding installs in general, I wholy agree with you...except for one problem: proprietary installs are just that - proprietary. There may be no way to determine where to even look for a product if the install information (or, rather, the uninstall information) doesn't tell you. This is another reason why Windows Installer kicks butt: it's a relational database and tracks everything from files, registry entries, and feature and component installation states. :)

                Microsoft MVP, Visual C# My Articles

                P Offline
                P Offline
                Peter Nirschl
                wrote on last edited by
                #7

                First I want to thank you all for your great help. All I wanted to do is to check if the Visual C++ Toolkit 2003 is installed on a system. I give my programs only to users who uses the Uninstall packages. So there won't be problems with deleting program directories or something. But there is only interesting thing: When I open my Control Panel and double click "Software" (in German) or "Add Or Remove Programs" (something like that in English). However, I got a list with all currently installed programs. How is this?

                H 1 Reply Last reply
                0
                • P Peter Nirschl

                  First I want to thank you all for your great help. All I wanted to do is to check if the Visual C++ Toolkit 2003 is installed on a system. I give my programs only to users who uses the Uninstall packages. So there won't be problems with deleting program directories or something. But there is only interesting thing: When I open my Control Panel and double click "Software" (in German) or "Add Or Remove Programs" (something like that in English). However, I got a list with all currently installed programs. How is this?

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #8

                  Add/Remove Programs uses the IAppPublisher shell interface, a COM interface not available in .NET, though you can declare it in managed code. COM servers containing implementations of IAppPublisher are in the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\AppManagement\Publishers registry key. Unfortunately, COM interop with .NET requires that you import the typelibs - if available - from each of these before you can create an instance of them. So, I recommend reading about the IAppPublisher interface in the MSDN Online Library[^] and creating a mixed-mode Managed C++ assembly. This way, you can work with native COM and expose the functionality you need to managed code. Writing an MC++ assembly this way allows you to reference it in your other managed projects, like a C# project.

                  Microsoft MVP, Visual C# My Articles

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups