none
Installation Date of Visual Studio RRS feed

  • Question

  • Hi there,

    I want to get Installation time of Visual Studio in my system, using a c# method.

    I hope that some class must have a method to get the time .

    Can anyone help me? I have searched Object Browser and I found  Upgrade().

    I think that Upgrade may be using the installation time. But I am not able to figure it out.

    _______________________________________________________________________

    public virtual void Upgrade()
        Member of System.Configuration.ApplicationSettingsBase

    Summary:
    Updates application settings to reflect a more recent installation of the application.

    ____________________________________________________________________

    I want to get Installation time of visual studio.

    Saturday, October 27, 2012 7:02 AM

Answers

  • Try below code using WMI.

    string productName = "Microsoft Visual Studio Professional 2012";
    DateTime installDate = default(DateTime);
    ManagementClass wmi = new ManagementClass("Win32_Product");
    var products = wmi.GetInstances();
    foreach (var item in products)
    {
        string pName = Convert.ToString(item["Description"]);
        if (pName.Contains(productName))
        {
            installDate = DateTime.ParseExact(Convert.ToString(item["InstallDate"]), "yyyyMMdd", null);
            break;
        }
    }
    
    MessageBox.Show(string.Format("{0} is installed on {1}",
    productName, installDate.ToShortDateString()));

    Note: You need to add reference to System.Management to your project.

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Marked as answer by Muhammad VP Monday, October 29, 2012 10:57 PM
    Saturday, October 27, 2012 7:26 AM

All replies

  • Try below code using WMI.

    string productName = "Microsoft Visual Studio Professional 2012";
    DateTime installDate = default(DateTime);
    ManagementClass wmi = new ManagementClass("Win32_Product");
    var products = wmi.GetInstances();
    foreach (var item in products)
    {
        string pName = Convert.ToString(item["Description"]);
        if (pName.Contains(productName))
        {
            installDate = DateTime.ParseExact(Convert.ToString(item["InstallDate"]), "yyyyMMdd", null);
            break;
        }
    }
    
    MessageBox.Show(string.Format("{0} is installed on {1}",
    productName, installDate.ToShortDateString()));

    Note: You need to add reference to System.Management to your project.

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Marked as answer by Muhammad VP Monday, October 29, 2012 10:57 PM
    Saturday, October 27, 2012 7:26 AM
  • Hey, thanks for your reply,

    It worked. so cool

    :):)

    Monday, October 29, 2012 10:57 PM