how to tell what version of windows and/or cmd.exe

2019-03-18 04:31发布

How can one determine what version of Windows and/or cmd.exe a batch file is running on?

There is no cmd /version that I've been able to find and the results of SET in a command prompt session don't give anything obviously unique (between XP and Win7 anyway).

标签: windows cmd
8条回答
三岁会撩人
2楼-- · 2019-03-18 05:00

I found a shorter way using ver as well:

...
ver | find "5.1"
if %ERRORLEVEL% == 0 goto ver_winxp
...

This will find XP, replace the string with your wanted versions

查看更多
Rolldiameter
3楼-- · 2019-03-18 05:05

I found a shorter way using ver as well:

Could be even shorter:

ver | find "5.1" >nul && goto ver_winxp
查看更多
登录 后发表回答