Reputation: 1
I m struggling with the windows build number, i want to get it in full size, therefore decimal are included, I have only found this code:
version = sys.getwindowsversion()
print(version.build)
the output is:
19043
but i need to get the full length of the build number :C, how can I overcome this issue?
SOLUTION FOUNDED:
import os
os.system('ver')
OUTPUT:
Microsoft Windows [Version 10.0.19043.1052]
ty everyone
Upvotes: 0
Views: 217
Reputation: 109
You got the acces to the rest of the build numbers via version.major
, version.minor
sys.getwindowsversion(major=10, minor=0, build=19041, platform=2, service_pack='')
Alternatively you can use
import platform
platform.version()
platfotm.platform()
the output looks like :
'10.0.19041'
'Windows-10-10.0.19041-SP0'
Its one more option. Run powershell script from python and catch the output. First thing to do is allow run powershell commands from outside : Set-ExecutionPolicy RemoteSigned
run in PS Than use code like :
import subprocess, sys
p = subprocess.Popen(["powershell.exe",
"Get-ItemProperty -Path c:\windows\system32\hal.dll.VersionInfo.FileVersion"],
stdout=sys.stdout)
p.communicate()
the output should be like :
10.0.19041.964 (WinBuild.160101.0800)
Upvotes: 1