How can I get the Original Install Date of the Windows using C#?
-
its asked somewhere earlier please do search in this site only! – uday Jun 21 '12 at 07:33
-
Maybe like Created Date of the Windows folder – V4Vendetta Jun 21 '12 at 07:33
-
Yes this is a straight up duplicate. See your Question and answer here : http://stackoverflow.com/questions/170617/how-do-i-find-the-install-time-and-date-of-windows – gideon Jun 21 '12 at 07:34
-
Sorry for not seeing the previous question. :) – Bill Gim Jun 21 '12 at 07:48
-
The creation date of windows/program files/user-folders is not the date of installation...my machine was installed 2011 and the folders where created 2009 – webber2k6 Jun 21 '12 at 09:29
2 Answers
From this website, using the registry rather than WMI (untested):
public static DateTime GetWindowsInstallationDateTime(string computerName)
{
Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, computerName);
key = key.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", false);
if (key != null)
{
DateTime installDate =
DateTime.FromFileTimeUtc(
Convert.ToInt64(
key.GetValue("InstallDate").ToString()));
return installDate;
}
return DateTime.MinValue;
}

- 3,865
- 1
- 30
- 38

- 29,818
- 9
- 60
- 82
-
1@BillGim: the regkey was missing some backslashes. the current version should do the trick – Nuffin Jun 21 '12 at 08:07
-
-
the DateTime constructor lacks of a DateTimeKind.Utc flag to produce the exact same date as the one produced/represented by the Microsoft's systeminfo.exe command-line tool. I added the modification in the original answer. – ElektroStudios May 23 '18 at 08:08
The HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate is the Windows InstallDate using a Unix timestamp, but technically it's the wrong date.
Let me explain;
The definition of UNIX timestamp is time zone 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 give you the date in NY timezone, not in Seattle timezone where Windows was original installed. It's the wrong date, it doesn't store timezone where the computer was initially installed.
Solution
- Change you computer time zone (right-click on you clock->Adjust date/time->Adjust time zone) to the time zone where windows was installed, or first turned on. Then run systeminfo.exe find /i "Original Install Date"
- HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate but you have add the time zone where windows was installed, or first turned on.

- 420
- 3
- 7