Installation date

S

Steven Hook

Hey,
Does Windows store a date of when it was installed in the registry? if so,
where?
Steven
 
A

Ariel Morg

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

Unfortunately I have no clue to how to translate int a readable date , maybe
someone do ?

Ariel
 
S

Steven Hook

Ariel Morg said:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion , REG_DWORD
InstallDate

Unfortunately I have no clue to how to translate int a readable date , maybe
someone do ?

Ariel

Thanks!!
I'll do some googleing :)
Steven
 
M

Matthias Tacke

Dim WshShell, TimeStamp
Set WshShell = WScript.CreateObject("WScript.Shell")

TimeStamp = WshShell.RegRead(_
"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\installdate")

WScript.Echo "Install date :" & _
DateAdd("s", TimeStamp, DateSerial(1970, 1, 1))

HTH
 
M

Matthias Tacke

Matthias Tacke wrote:
I hope it was obvious to everyone that this is a vbscript ;-)

A batch solution follows (requires reg.exe in XP standard or w2kreskit)
Dim WshShell, TimeStamp
Set WshShell = WScript.CreateObject("WScript.Shell")

TimeStamp = WshShell.RegRead(_
"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\installdate")

WScript.Echo "Install date :" & _
DateAdd("s", TimeStamp, DateSerial(1970, 1, 1))

::GetInstallDate.cmd:::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
set Key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
set Val=InstallDate
for /f "tokens=3" %%A in (
'REG Query "%Key%" /v %Val%^|findstr /I "%Val%.*REG_"'
) do set Instsecs=%%A
set Inst
call :SecsToDate %Instsecs% YY MM DD HH NN SS
echo Installdate: %YY%-%MM%-%DD% %HH%:%NN%:%SS%
goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:SecsToDate %secs% yy mm dd hh nn ss
::
:: By: Ritchie Lawrence, updated 2002-07-24. Version 1.1
:: http://www.commandline.co.uk/lib/treeview/index.php
:: Func: Returns a calendar date and time of day from the number of
:: elapsed seconds since 1st January 1970 00:00:00. For
:: NT4/2000/XP/2003.
:: Args:
:: %1 seconds used to create calendar date and time of day (by val)
:: %2 var to receive year, 4 digits for all typical dates (by ref)
:: %3 var to receive month, 2 digits, 01 to 12 (by ref)
:: %4 var to receive day of month, 2 digits, 01 to 31 (by ref)
:: %5 var to receive hours, 2 digits, 00 to 23 (by ref)
:: %6 var to receive minutes, 2 digits, 00 to 59 (by ref)
:: %7 var to receive seconds, 2 digits, 00 to 59 (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS
set /a i=%1,ss=i%%60,i/=60,nn=i%%60,i/=60,hh=i%%24,dd=i/24,i/=24
set /a a=i+2472632,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2
set /a dd/=5,dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
(if %hh% LSS 10 set hh=0%hh%)&(if %nn% LSS 10 set nn=0%nn%)
if %ss% LSS 10 set ss=0%ss%
endlocal&set %7=%ss%&set %6=%nn%&set %5=%hh%&^
set %4=%dd%&set %3=%mm%&set %2=%yy%&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
S

Steven Hook

Matthias Tacke said:
Matthias Tacke wrote:
I hope it was obvious to everyone that this is a vbscript ;-)

A batch solution follows (requires reg.exe in XP standard or w2kreskit)

::GetInstallDate.cmd:::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
set Key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
set Val=InstallDate
for /f "tokens=3" %%A in (
'REG Query "%Key%" /v %Val%^|findstr /I "%Val%.*REG_"'
) do set Instsecs=%%A
set Inst
call :SecsToDate %Instsecs% YY MM DD HH NN SS
echo Installdate: %YY%-%MM%-%DD% %HH%:%NN%:%SS%
goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:SecsToDate %secs% yy mm dd hh nn ss
::
:: By: Ritchie Lawrence, updated 2002-07-24. Version 1.1
:: http://www.commandline.co.uk/lib/treeview/index.php
:: Func: Returns a calendar date and time of day from the number of
:: elapsed seconds since 1st January 1970 00:00:00. For
:: NT4/2000/XP/2003.
:: Args:
:: %1 seconds used to create calendar date and time of day (by val)
:: %2 var to receive year, 4 digits for all typical dates (by ref)
:: %3 var to receive month, 2 digits, 01 to 12 (by ref)
:: %4 var to receive day of month, 2 digits, 01 to 31 (by ref)
:: %5 var to receive hours, 2 digits, 00 to 23 (by ref)
:: %6 var to receive minutes, 2 digits, 00 to 59 (by ref)
:: %7 var to receive seconds, 2 digits, 00 to 59 (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS
set /a i=%1,ss=i%%60,i/=60,nn=i%%60,i/=60,hh=i%%24,dd=i/24,i/=24
set /a a=i+2472632,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2
set /a dd/=5,dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
(if %hh% LSS 10 set hh=0%hh%)&(if %nn% LSS 10 set nn=0%nn%)
if %ss% LSS 10 set ss=0%ss%
endlocal&set %7=%ss%&set %6=%nn%&set %5=%hh%&^
set %4=%dd%&set %3=%mm%&set %2=%yy%&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Thanks!!
I have no Idea about VB Scripts, but someone asked me about this, so I'll
pass the info on to him, he'll LOVE you for it!
Thanks All!
Steven
 
M

Mark V

In said:
Hey,
Does Windows store a date of when it was installed in the
registry? if so, where?
Steven

An additional tip that may be of interest (although not actually
"stored in the registry").

The hive files on disk at
%systemroot%\repair
are stamped with the approximate OS installation date/time
 
M

Matthias Tacke

Jerold said:
See tip 8180 in the 'Tips & Tricks' at http://www.jsiinc.com
to avoid any line wrap in messages.
The version of SecsToDate I use is reformatted to 70 chars to avoid
breaks from newsreaders. Although my TB1.0 itself breaks only at
pos 132 (That's why my sig as a ruler ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top