Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Another question elligeable for a '<strong><a href="https://stackoverflow.com/questions/172184">code-challenge</a></strong>': here are some source code executables to answer the problem, but they are not complete.<br> Will you find a vb script that anyone can execute on his/her computer, with the expected result ?</p> <hr> <pre><code>systeminfo|find /i "original" </code></pre> <p>would give you the actual date... not the number of seconds ;)<br> As <a href="https://stackoverflow.com/users/1656624/sammy">Sammy</a> <a href="https://stackoverflow.com/questions/170617/how-do-i-find-the-install-time-and-date-of-windows/170634#comment30361382_170634">comments</a>, <code>find /i "install"</code> gives more than you need.<br> And this only works if the locale is English: It needs to match the language.<br> For Swedish this would be "<code>ursprungligt</code>" and "<code>ursprüngliches</code>" for German.</p> <hr> <p>In Windows <a href="http://en.wikipedia.org/wiki/Windows_PowerShell" rel="noreferrer">PowerShell</a> script, you could just type:</p> <pre><code>PS &gt; $os = get-wmiobject win32_operatingsystem PS &gt; $os.ConvertToDateTime($os.InstallDate) -f "MM/dd/yyyy" </code></pre> <p>By using WMI (<a href="http://en.wikipedia.org/wiki/Windows_Management_Instrumentation" rel="noreferrer">Windows Management Instrumentation</a>)</p> <p>If you do not use WMI, you must read then convert the registry value:</p> <pre><code>PS &gt; $path = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' PS &gt; $id = get-itemproperty -path $path -name InstallDate PS &gt; $d = get-date -year 1970 -month 1 -day 1 -hour 0 -minute 0 -second 0 ## add to hours (GMT offset) ## to get the timezone offset programatically: ## get-date -f zz PS &gt; ($d.AddSeconds($id.InstallDate)).ToLocalTime().AddHours((get-date -f zz)) -f "MM/dd/yyyy" </code></pre> <p>The rest of this post gives you other ways to access that same information. Pick your poison ;)</p> <hr> <p>In VB.Net that would give something like:</p> <pre><code>Dim dtmInstallDate As DateTime Dim oSearcher As New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem") For Each oMgmtObj As ManagementObject In oSearcher.Get dtmInstallDate = ManagementDateTimeConverter.ToDateTime(CStr(oMgmtO bj("InstallDate"))) Next </code></pre> <hr> <p>In <a href="http://www.autoitscript.com/autoit3/" rel="noreferrer">Autoit</a> (a Windows scripting language), that would be:</p> <pre><code>;Windows Install Date ; $readreg = RegRead("HKLM\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\", "InstallDate") $sNewDate = _DateAdd( 's',$readreg, "1970/01/01 00:00:00") MsgBox( 4096, "", "Date: " &amp; $sNewDate ) Exit </code></pre> <hr> <p>In Delphy 7, that would go as:</p> <pre><code>Function GetInstallDate: String; Var di: longint; buf: Array [ 0..3 ] Of byte; Begin Result := 'Unknown'; With TRegistry.Create Do Begin RootKey := HKEY_LOCAL_MACHINE; LazyWrite := True; OpenKey ( '\SOFTWARE\Microsoft\Windows NT\CurrentVersion', False ); di := readbinarydata ( 'InstallDate', buf, sizeof ( buf ) ); // Result := DateTimeToStr ( FileDateToDateTime ( buf [ 0 ] + buf [ 1 ] * 256 + buf [ 2 ] * 65535 + buf [ 3 ] * 16777216 ) ); showMessage(inttostr(di)); Free; End; End; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload