Created
March 7, 2012 02:46
-
-
Save wangye/1990565 to your computer and use it in GitHub Desktop.
VBScript Get Windows OS installation date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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