luni, 26 octombrie 2009

Wscript windows install date

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

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

WScript.Echo "Install date mm/dd/yyyy :" & _DateAdd("s", TimeStamp, DateSerial(1970, 1, 1)) '

WBScript DateSerial Function

The DateSerial function returns a Variant of subtype Date for a specified year, month, and day.

Syntax: DateSerial(year,month,day)




yearRequired. A number between 100 and 9999, or a numeric expression. Values between 0 and 99 are interpreted as the years 1900–1999. For all other year arguments, use a complete four-digit year
monthRequired. Any numeric expression
dayRequired. Any numeric expression

Example:



document.write(DateSerial(1996,2,3))2/3/1996
document.write(DateSerial(1990-20,9-2,1-1))6/30/1970


WBScript DateAdd Function

The DateAdd function returns a date to which a specified time interval has been added.

Syntax: DateAdd(interval,number,date)




intervalRequired. The interval you want to add

Can take the following values:

* yyyy - Year
* q - Quarter
* m - Month
* y - Day of year
* d - Day
* w - Weekday
* ww - Week of year
* h - Hour
* n - Minute
* s - Second
numberRequired. The number of interval you want to add. Can either be positive, for dates in the future, or negative, for dates in the past
dateRequired. Variant or literal representing the date to which interval is added

Example:



document.write(DateAdd("m",1,"31-Jan-00"))2/29/2000
document.write(DateAdd("m",1,"31-Jan-01"))2/28/2001