检测 Windows 10 版并根据它采取行动的批处理脚本

Batch script that detect Windows 10 edtition and act depending on it

所以我想要的是一个批处理脚本,它将根据用户拥有的 Windows 10 版本进行操作。所以现在我确实有一个带有 case 的基本脚本,但它需要用户输入。所以我想 help/tips 了解如何编写它。 提前致谢

由于Windows 10有WMIC.exe,这里有一个可能对你有帮助的解决方案:

@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Set /A "SKU=OSV=0"
For /F "EOL=O Tokens=1,2 Delims=. " %%G In ('%SystemRoot%\System32\wbem\WMIC.exe
 OS Where "Version>10" Get OperatingSystemSKU^, Version 2^>NUL'
) Do Set /A "SKU=%%G, OSV=%%H" 2>NUL
If Not %OSV% Equ 10 GoTo :EOF
For /F "Tokens=1,* Delims=:" %%G In ('%SystemRoot%\System32\findstr.exe
 "^::%SKU%:" "%~f0"') Do Set "EDN=Windows %OSV% %%H"
Echo %%EDN%% = %EDN%
Pause
GoTo :EOF
Rem Windows 10 Editions
::4:Enterprise
::27:Enterprise N
::48:Professional
::49:Professional N
::72:Enterprise Evaluation
::84:Enterprise N Evaluation
::98:Home N
::99:Home China
::100:Home single language
::101:Home
::119:TeamOS
::121:Education
::122:Education N
::123:IoT Core
::125:Enterprise LTSB
::126:Enterprise LTSB N
::129:Enterprise LTSB Evaluation
::130:Enterprise LTSB N Evaluation
::131:IoT Core Commercial
::136:Holographic
::138:Professional Single Language
::161:Professional for workstation
::162:Professional for workstation N
::164:10 Professional Education
::165:Professional Education N
::171:Enterprise G
::172:Enterprise G N
::175:Enterprise Multi-session
::188:IoT Enterprise