Click here to Skip to main content
12,816,270 members (35,111 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 27 Dec 2013

Get Version of a Software using C#

, 29 Dec 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Get Version of any software on MSI installed in any System/Server


This DLL will get you the Version of the software that is present in your installed programs in control panel. This is specially use full when we might need to get the MSI version of any product that we drop in servers.

Using the code

//Download the "ReadSoftwareVersion.dll" from the attachments and add it to the references of your project 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ReadSoftwareVersion;

namespace TestVersion
    class Program
        static void Main(string[] args)
            Software objVersion = new Software();
            string version = objVersion.GetSoftwateVersion("Your Software Name");
// This is a Wild Card Search. You need not give full name for "Your Software Name" 

Actual Code inside the "ReadSoftwareVersion.dll" 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;  // Include this in references

namespace ReadSoftwareVersion
    // your own class name
    public class Software
        // Method that will fetch the version of a given software
        public string GetSoftwateVersion(string softWareName)
            string strVersion = string.Empty;
                var version = (object)null;
                //Query the system registery for the verion of the given software                
                var searcher = new ManagementObjectSearcher(
                  "SELECT * FROM Win32_Product where Name LIKE " + 
                  "'%" + softWareName + "%'");
                foreach (ManagementObject obj in searcher.Get())
                    version = obj["Version"];
                if (version != null)
                    strVersion = (String)version;
                // if given product is not found in list of installed products in control panel
                    strVersion = "Given Product is not found the list of Installed Programs";
            // Exception Handling
            catch (Exception e)
                strVersion = "An Error occured while fetching Version" + 
                  " (" + e.Message + ")";
            return strVersion;

Here just a Console Application is shown for DEMO. In general, this dll can be added to any project, i.e to web application.... where ever needed.

Points of Interest

This will specially help in the cases where we need to fetch the MSI information of the product that is dropped in remote server. Generally, we might need to follow with installation teams to get the MSI Version. But using this we can fetch the MSI Version and display it in UI, if needed. This method is relatively slow and will take around 10 to 20 seconds to execute. This is completely tested and 100% working.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Dinesh Thammineni
Systems Engineer
India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralFile download Problem Pin
Abhishek Pant27-Dec-13 19:38
memberAbhishek Pant27-Dec-13 19:38 
GeneralRe: File download Problem Pin
Dinesh Thammineni28-Dec-13 20:09
professionalDinesh Thammineni28-Dec-13 20:09 
GeneralRe: File download Problem Pin
Abhishek Pant29-Dec-13 20:51
memberAbhishek Pant29-Dec-13 20:51 
Questioncannot download source file Pin
fredatcodeproject27-Dec-13 15:21
memberfredatcodeproject27-Dec-13 15:21 
AnswerRe: cannot download source file Pin
Dinesh Thammineni28-Dec-13 20:10
professionalDinesh Thammineni28-Dec-13 20:10 
GeneralRe: cannot download source file Pin
fredatcodeproject30-Dec-13 13:02
memberfredatcodeproject30-Dec-13 13:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 29 Dec 2013
Article Copyright 2013 by Dinesh Thammineni
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid