I want exactly the same output as winver
only on the command line. For example, on my machine running winver
returns this:
I need a command line alternative that would return 1909. I know how to get the 18363 piece - [environment]::OSVersion.Version.Build
(in powershell). Googling reveals several options, none of which tell me that the version is 1909:
wmic os get
systeminfo
Now maybe they encode it differently, I do not know. Ideally I want to get the Version and the OS Build.
EDIT 1
I am OK to read it from registry, since it can be done on the command line.
EDIT 2
Thanks to a hint from dxiv I found it:
(get-itemproperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId
The " Version " number displayed in winver
matches the ReleaseID
value from the registry key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion
, and circumstantial evidence suggests that there is no API to retrieve it, other than reading it from the registry (per my previous answer here ).
The following reads the version number from the registry into a Version
environment variable at the cmd
prompt (double the %%a
, %%c
percents when using in a batch file).
C:\etc>for /f "tokens=1-3" %a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ReleaseID') do @set "Version=%~c"
C:\etc>echo Version = '%Version%'
Version = '2004'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.