winver's dialog displays 14393.447 for example, but ver at the command line only displays 10.0.14393. What's the easiest and most reliable way to get the 447 portion using a batch file that'll work on all Win10 versions? Edit: Sigh... To clarify for those who can't understand what "via batch" means, I need the minor build number accessible for further processing in a batch file/script.
Ok, so I'm not sure whether you're simply trying to crack a silly joke or being serious. If the latter, besides the fact that winver can be launched from a non admin cmd prompt too, how do you propose to access its output via a batch script? If I simply wanted to look up the number in a GUI dialog why would I bother with a batch file? Honestly, this being MDL I didn't really think I'd need to spell out what "via batch" meant...
Not too good with cmd.. but powershell: Code: function Get-RegistryValue($key, $value) { (Get-ItemProperty $key $value).$value } $a1 = Get-RegistryValue "HKLM:\Software\Microsoft\Windows NT\CurrentVersion" UBR Write-Host $a1 Hope it helps..
Code: @echo OFF setlocal ENABLEEXTENSIONS set REG_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" set KEY_NAME=CurrentBuild set KEY_SUBBUILD=UBR FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %REG_NAME% /v %KEY_NAME% 2^>nul`) DO (@echo %%C) FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %REG_NAME% /v %KEY_SUBBUILD% 2^>nul`) DO (@echo %%C)
You can use this in a batch file to find minor build Code: @ECHO OFF SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION FOR /F "tokens=2 delims=." %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildLabEx') Do (Set Minor=%%A) Echo:Minor Build = %Minor% Pause Exit
Thanks, but for now I prefer the UBR DWORD mentioned above since it specifically contains only the minor build number. I just need to confirm that it's present right from Win10 RTM onwards and in various versions of the OS. If not then I'll check BuildLabEx but probably the file version check would be most reliable even though it's slower than reg access.
I only have 14393 ISOs lying around, sorry, so I can't check the actual behaviour of Windows on previous versions, but I think reading UBR from the registry is the best way, indeed, compared to the file version check, as Microsoft themselves read UBR etc. in winver (well, ShellAbout) on 14393 to determine the displayed version information. On 10240 (I found a copy of its shell32.dll on dll-files.com), ShellAbout uses GetVersionExW and if you look at screenshots of 10240's about dialog on the Internet, you'll notice the lack of a minor build number on them. I don't think GetVersionExW can display such information, as I couldn't find a member containing the same value as the UBR registry value in any of the fields of RTL_OSVERSIONINFOEXW (though, I am very inexperienced with the WinAPI, so take from that what you will). In 10.0.10586.11's shell32.dll, ShellAbout reads UBR there too. I can only assume that it's the same for 10.0.10586.494's shell32.dll.
All very useful information, thanks! I plan to check the older versions in a VM later, but for now UBR is what I'm using (with set /a to convert it from hex to dec in batch).
then a "proper" version would be Code: @echo off for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuild') do set /a version=%%a for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR') do set /a mbn=%%a echo Windows Version: %version%.%mbn%
Yeah, except CurrentBuild being a REG_SZ doesn't need /a with set, unlike UBR which is a REG_DWORD and returns a hex value.