下面的批处理(扩展名BAT或者CMD) 可以在几乎任何一个WIN操作系统上运行 该脚本会利用 ver 和 find 命令来判断版本号 并给出相应的WIN系统.
@echo off
ver | find "5.1" > nul
if errorlevel = 1 goto next0
if errorlevel = 0 goto xp
:next0
ver | find "6.0" > nul
if errorlevel = 1 goto next
if errorlevel = 0 goto win vista
:next
ver | find "6.1"
if errorlevel = 1 goto next1
if errorlevel = 0 goto win7
:next1
ver | find "6.2" > nul
if errorlevel = 1 goto next2
if errorlevel = 0 goto win8
:next2
ver | find "6.3" > nul
if errorlevel = 1 goto next3
if errorlevel = 0 goto win8.1
:next3
ver | find "6.3" > nul
if errorlevel = 1 goto next4
if errorlevel = 0 goto win8.1
:next4
ver | find "10.0" > nul
if errorlevel = 1 goto other
if errorlevel = 0 goto win10
:xp
echo XP
goto :eof
:win vista
echo Vista
goto :eof
:win7
echo Win7
goto :eof
:win8
echo Win8
goto :eof
:win8.1
echo Win8.1
goto :eof
:win10
echo Win10
goto :eof
:other
echo Early Win
goto :eof
在我机器 上 ver 命令给出这样的输出 之后就可以用 find 命令寻找相应的版本号 然后用 errorlevel 上一条命令返回值来进行判断 为0的时候表示找到了匹配 否则进行下一个版本的判断.
Microsoft Windows [Version 6.3.9600]
win-batch-script-to-detect-version
英文: https://helloacm.com/windows-batch-script-to-detect-windows-version/
强烈推荐
- 英国代购-畅购英伦
- TopCashBack 返现 (英国购物必备, 积少成多, 我2年来一共得了3000多英镑)
- Quidco 返现 (也是很不错的英国返现网站, 返现率高)
- 注册就送10美元, 免费使用2个月的 DigitalOcean 云主机(性价比超高, 每月只需5美元)
- 注册就送10美元, 免费使用4个月的 Vultr 云主机(性价比超高, 每月只需2.5美元)
- 注册就送10美元, 免费使用2个月的 阿里 云主机(性价比超高, 每月只需4.5美元)
- 注册就送20美元, 免费使用4个月的 Linode 云主机(性价比超高, 每月只需5美元) (折扣码: PodCastInit2022)
- PlusNet 英国光纤(超快, 超划算! 用户名 doctorlai)
- 刷了美国运通信用卡一年得到的积分 换了 485英镑
- 注册就送50英镑 – 英国最便宜最划算的电气提供商
- 能把比特币莱特币变现的银行卡! 不需要手续费就可以把虚拟货币法币兑换
微信公众号: 小赖子的英国生活和资讯 JustYYUK