本文介绍了Windows批处理OS版本检查是否支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为Windows 10制作"BatchGameHub",现在我正在.batch中制作安装程序,但是我不知道如何检查Windows版本(10、8、7)以及if命令的支持.示例我的意思是:(检查版本的命令)
I'm making "BatchGameHub" for windows 10, and right now I'm making installer in .batch, but I don't know how to check windows version (10, 8, 7) and with support with if command.Example what I mean:(Command to check version)
if %winversion%== 10 goto start
goto win_not_compatible
:win_not_compatible
echo.
echo Your windows version cannot run gamehub!
echo [ Press any key to cancel installer... ]
echo.
pause>null
exit
推荐答案
使用WMIC
执行您的问题要求,这应该可行:
To do what your question asks using WMIC
this should work:
@Echo Off
Set "OV="
For /F "Skip=1 Tokens=*" %%A In (
'WMIC OS Where "Version<'4'" Get Version 2^>Nul') Do For %%B In (%%A
) Do Set "OV=%%A"
If Defined OV GoTo Start
Echo=
Echo Your windows version cannot run gamehub!
Echo [ Press any key to cancel installer... ]
Echo=
Pause>Nul
Exit /B
:Start
我仅在Windows 10上将<
与4
用作GoTo Start
,因为字符串比较会发现第一个字符1
小于4
等.(Windows 10或Windows 10较新.)
I used <
with 4
to GoTo Start
only on Windows 10, because a string comparison will find that the first character, 1
is less than 4
etc. (Windows 10 or newer.)
这篇关于Windows批处理OS版本检查是否支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!