本文介绍了在批处理文件中获取Windows版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要得到一个批处理文件的操作系统版本。我见过很多例子在线,许多使用这样的事情code:
I need to get the OS version with a batch file. I 've seen a lot of examples online, many uses something like this code:
@echo off
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit
systeminfo | find "OS Name" > %TEMP%\osname.txt
FOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO set vers=%%i
echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto ver_7
echo %vers% | find "Windows Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
goto warnthenexit
:ver_7
:Run Windows 7 specific commands here.
echo Windows 7
goto exit
:ver_vista
:Run Windows Vista specific commands here.
echo Windows Vista
goto exit
:ver_xp
:Run Windows XP specific commands here.
echo Windows XP
goto exit
:warnthenexit
echo Machine undetermined.
:exit
问题是,当我执行这个在Vista或Windows 7我得到的消息
The problem is when I execute this on Vista or Windows 7 I get the message
机未定
是否有任何其他的方式做我想要什么?
Is there any other way to do what I want?
推荐答案
您是否尝试过使用 WMIC
命令?
Have you tried using the wmic
commands?
尝试 WMIC操作系统版本获得
这会给你在命令行版本号,那么你只需要融入批处理文件。
This will give you the version number in a command line, then you just need to integrate into the batch file.
这篇关于在批处理文件中获取Windows版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!