检测 Windows 10 版本并根据它执行操作的批处理脚本

发布于 2025-01-11 07:36:25 字数 127 浏览 0 评论 0原文

因此,id 想要的是一个批处理脚本,该脚本将根据用户拥有的 Windows 10 版本进行操作。所以现在我确实有一个带有 case 的基本脚本,但它需要用户输入。所以我想要一些关于如何编写它的帮助/提示。 提前致谢

so what id like to have is a batch script that will act depending on the Windows 10 edition the user has. So right now I do have a basic script with a case but it requires the user input. So I would like some help/tips on how to write that.
Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守不住的情 2025-01-18 07:36:25

由于 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

As Windows 10 has WMIC.exe, here's a possible solution which may be of assistance to you:

@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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文