Created
October 7, 2023 14:57
-
-
Save PIRANY1/60b0af0262e498c88bc8c006b026697c to your computer and use it in GitHub Desktop.
Get Windows OS info per batch
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
@echo off | |
prompt $g | |
Set UseExpresssion=Reg Query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName" | |
for /F "tokens=*" %%X IN ('%UseExpresssion%') do Set OSEdition=%%X | |
Set OSEdition=%OSEdition:*REG_SZ =% | |
If Defined ProgramFiles(x86) (Set OSType=x64) Else (Set OSType=x86) | |
Set UseExpresssion=Reg Query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ReleaseId" | |
for /F "tokens=*" %%X IN ('%UseExpresssion%') do Set OSVersion=%%X | |
Set OSVersion=%OSVersion:*REG_SZ =% | |
If %OSVersion% LSS 2009 GoTo BuildNo | |
Set UseExpresssion=Reg Query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "DisplayVersion" | |
for /F "tokens=*" %%X IN ('%UseExpresssion%') do Set OSVersion=%%X | |
Set OSVersion=%OSVersion:*REG_SZ =% | |
:BuildNo | |
Set UseExpresssion=Ver | |
for /F "tokens=*" %%X IN ('%UseExpresssion%') do Set OSBuild=%%X | |
Set OSBuild=%OSBuild:*10.0.=% | |
Set OSBuild=%OSBuild:~0,-1% | |
echo %OSEdition% | |
echo Type: %OSType% | |
echo Version: %OSVersion% | |
echo Build: %OSBuild% | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment