Created
July 16, 2016 22:01
-
-
Save thurask/aec4728cb34cb7efcb65696a402f1146 to your computer and use it in GitHub Desktop.
Windows 10 build ID and date info
This file contains 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
import datetime | |
import time | |
import winreg | |
import pytz | |
def gets(): | |
hive = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion") | |
keys = ("ProductName", "ReleaseId") | |
info = {key: winreg.QueryValueEx(hive, key)[0] for key in keys} | |
blex = winreg.QueryValueEx(hive, "BuildLabEx")[0] | |
stamps = ("build", "revision", "type", "lab", "stamp") | |
builds = blex.split(".") | |
for idx, itm in enumerate(stamps): | |
info[itm] = builds[idx] | |
del info["type"] | |
isdst = bool((pytz.timezone("America/Los_Angeles").localize(datetime.datetime.strptime(info["stamp"], "%y%m%d-%H%M"))).dst()) | |
bzone = "Pacific Daylight Time" if isdst else "Pacific Standard Time" | |
info["date"] = time.strftime("%A %d %B %Y %H:%M {0}".format(bzone), time.strptime(info["stamp"], "%y%m%d-%H%M")) | |
idate = winreg.QueryValueEx(hive, "InstallDate")[0] | |
izone = time.strftime("%Z", time.localtime(idate)) | |
info["idate"] = time.strftime("%A %d %B %Y %H:%M %Z", time.localtime(idate)) | |
del info["stamp"] | |
return info | |
def puts(): | |
info = gets() | |
print("{0} version {1} build {2}.{3}".format(info["ProductName"], info["ReleaseId"], info["build"], info["revision"])) | |
print("Built by {0} on {1}".format(info["lab"], info["date"])) | |
print("Installed on {0}".format(info["idate"])) | |
if __name__ == "__main__": | |
puts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment