Skip to content

Instantly share code, notes, and snippets.

@bhensley
Created June 2, 2014 12:21
Show Gist options
  • Save bhensley/67a1777b445ce21adb05 to your computer and use it in GitHub Desktop.
Save bhensley/67a1777b445ce21adb05 to your computer and use it in GitHub Desktop.
Check the registry for the known install date of a Windows system and output via InputBox (for easy copying). I never thought I'd be thankful for having learned Visual Basic a decade ago...
Dim shell, val, regKey
On Error Resume Next
' UNIX time of OS installation
regKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate"
' Invoke WScript and read the key
Set shell = CreateObject("WScript.Shell")
val = shell.RegRead(regKey)
' If an error was found then set "Not Found" otherwise set the found install date
If err.number <> 0 Then
readFromRegistry = "Not Found"
Else
readFromRegistry = val
End If
' Clean up
Set shell = Nothing
' And output to screen using InputBox, so it can be easily copied
Call InputBox("Install Date", "Windows Install Date", readFromRegistry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment