How do I find the install time and date of Windows?

后端 未结 20 1170
孤街浪徒
孤街浪徒 2020-12-12 11:36

This might sound like a little bit of a crazy question, but how can I find out (hopefully via an API/registry key) the install time and date of Windows?

The best I c

相关标签:
20条回答
  • 2020-12-12 11:59

    You can also check the check any folder in the system drive like "windows" and "program files". Right click the folder, click on the properties and check under the general tab the date when the folder was created.

    0 讨论(0)
  • 2020-12-12 12:00

    In regedit.exe go to:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate
    

    It's given as the number of seconds since January 1, 1970. (Note: for Windows 10, this date will be when the last feature update was installed, not the original install date.)

    To convert that number into a readable date/time just paste the decimal value in the field "UNIX TimeStamp:" of this Unix Time Conversion online tool.

    0 讨论(0)
  • 2020-12-12 12:04

    How to find out Windows 7 installation date/time:

    just see this...

    • start > enter CMD
    • enter systeminfo

    that's it; then you can see all information about your machine; very simple method

    0 讨论(0)
  • 2020-12-12 12:05

    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate and systeminfo.exe produces the wrong date.

    The definition of UNIX timestamp is timezone independent. The UNIX timestamp is defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970 and not counting leap seconds.

    In other words, if you have installed you computer in Seattle, WA and moved to New York,NY the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate will not reflect this. It's the wrong date, it doesn't store timezone where the computer was initially installed.

    The effect of this is, if you change the timezone while running this program, the date will be wrong. You have to re-run the executable, in order for it to account for the timezone change.

    But you can get the timezone info from the WMI Win32_Registry class.

    InstallDate is in the UTC format (yyyymmddHHMMSS.xxxxxx±UUU) as per Microsoft TechNet article "Working with Dates and Times using WMI" where notably xxxxxx is milliseconds and ±UUU is number of minutes different from Greenwich Mean Time.

     private static string RegistryInstallDate()
        {
    
            DateTime InstallDate = new DateTime(1970, 1, 1, 0, 0, 0);  //NOT a unix timestamp 99% of online solutions incorrect identify this as!!!! 
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Registry");
    
            foreach (ManagementObject wmi_Windows in searcher.Get())
            {
                try
                {
                    ///CultureInfo ci = CultureInfo.InvariantCulture;
                    string installdate = wmi_Windows["InstallDate"].ToString(); 
    
                    //InstallDate is in the UTC format (yyyymmddHHMMSS.xxxxxx±UUU) where critically
                    // 
                    // xxxxxx is milliseconds and       
                    // ±UUU   is number of minutes different from Greenwich Mean Time. 
    
                    if (installdate.Length==25)
                    {
                        string yyyymmddHHMMSS = installdate.Split('.')[0];
                        string xxxxxxsUUU = installdate.Split('.')[1];      //±=s for sign
    
                        int year  = int.Parse(yyyymmddHHMMSS.Substring(0, 4));
                        int month = int.Parse(yyyymmddHHMMSS.Substring(4, 2));
                        int date  = int.Parse(yyyymmddHHMMSS.Substring(4 + 2, 2));
                        int hour  = int.Parse(yyyymmddHHMMSS.Substring(4 + 2 + 2, 2));
                        int mins  = int.Parse(yyyymmddHHMMSS.Substring(4 + 2 + 2 + 2,  2));
                        int secs  = int.Parse(yyyymmddHHMMSS.Substring(4 + 2 + 2 + 2 + 2, 2));
                        int msecs = int.Parse(xxxxxxsUUU.Substring(0, 6));
    
                        double UTCoffsetinMins = double.Parse(xxxxxxsUUU.Substring(6, 4));
                        TimeSpan UTCoffset = TimeSpan.FromMinutes(UTCoffsetinMins);
    
                        InstallDate = new DateTime(year, month, date, hour, mins, secs, msecs) + UTCoffset; 
    
                    }
                    break;
                }
                catch (Exception)
                {
                    InstallDate = DateTime.Now; 
                }
            }
            return String.Format("{0:ffffd d-MMM-yyyy h:mm:ss tt}", InstallDate);      
        }
    
    0 讨论(0)
  • 2020-12-12 12:05

    Try this powershell command:

    Get-ChildItem -Path HKLM:\System\Setup\Source* | 
     ForEach-Object {Get-ItemProperty -Path Registry::$_} | 
         Select-Object ProductName, ReleaseID, CurrentBuild, @{n="Install Date"; e={([DateTime]'1/1/1970').AddSeconds($_.InstallDate)}} | 
             Sort-Object "Install Date"
    
    0 讨论(0)
  • 2020-12-12 12:07

    After trying a variety of methods, I figured that the NTFS volume creation time of the system volume is probably the best proxy. While there are tools to check this (see this link ) I wanted a method without an additional utility. I settled on the creation date of "C:\System Volume Information" and it seemed to check out in various cases.

    One-line of PowerShell to get it is:

    ([DateTime](Get-Item -Force 'C:\System Volume Information\').CreationTime).ToString('MM/dd/yyyy')
    
    0 讨论(0)
提交回复
热议问题