如何告诉什么版本的Windows和/或cmd.exe一个批处理文件正在运行? [英] how to tell what version of windows and/or cmd.exe a batch file is running on?

查看:121
本文介绍了如何告诉什么版本的Windows和/或cmd.exe一个批处理文件正在运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定运行批处理文件的Windows和/或cmd.exe的版本?



没有 cmd /版本,我已经能够找到,并且SET在命令提示符会话的结果不给任何明显的唯一(在XP和Win7之间)。


< cmd.exe 的版本实际上是不相关的,除非你请尝试使用之前不存在的功能(例如,在 command.com 中)。有伪变量

 %cmdextversion%

其中包含已经为2年龄(至少返回NT 4,iirc)的命令扩展版本。



但是,回到点:运行 ver 并解析版本字符串可能是你最好的选择:

  for / ftokens = 2 delims = []%% x in('ver')do set WINVER = %% x 
set WINVER =%WINVER:Version =%


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).

解决方案

The version of cmd.exe should actually be pretty irrelevant, unless you try to use features that didn't exist before (in command.com for example). There is the pseudovariable

%cmdextversion%

which holds the version of the command extensions which has been 2 for ages (at least back to NT 4, iirc).

But, back to the point: Running ver and parsing the version string might be your best bet:

for /f "tokens=2 delims=[]" %%x in ('ver') do set WINVER=%%x
set WINVER=%WINVER:Version =%

这篇关于如何告诉什么版本的Windows和/或cmd.exe一个批处理文件正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆