Skip to content

Instantly share code, notes, and snippets.

@wangye
Created March 7, 2012 02:46
Show Gist options
  • Save wangye/1990565 to your computer and use it in GitHub Desktop.
Save wangye/1990565 to your computer and use it in GitHub Desktop.
VBScript Get Windows OS installation date
Option Explicit
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_DWORD = 4
Function VBMain()
Dim strComputer, strKeyPath, lngValue, Registry
strComputer = "."
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
Set Registry = GetObject(_
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
Registry.GetDWORDValue HKEY_LOCAL_MACHINE,_
strKeyPath,_
"InstallDate",_
lngValue
WScript.Echo "Unix timestamp : " & lngValue
WScript.Echo "Normal DateTime : " &_
DateAdd("s", lngValue, "01/01/1970 00:00:00")
Set Registry = Nothing
End Function
WScript.Quit(VBMain())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment