我有这个代码的(testing)batch file
如果存在“C:\ Users \ All Users \ ntuser.dat”转到Win 7如果存在“C:\ Documents and Settings \ All Users \ ntuser.dat”转到Win XP
:Win 7将在这里写入将在win7上运行的参数
C:\ W7 \ test.txt的
:Win XP
将在这里写的参数将运行在winxp上
和其他os + os架构一样
它的工作,但我需要添加更多的操作系统识别选项..我需要该batch file来识别操作系统版本,体系结构(仅Windows 2003 R2 x64,Windows XP x32和x64,Windows Vista x32和x64,Windows 7 x32和x64,Windows 8 x32和x64)
先进的非常感谢!
Aacini在这里有一个很好的解决方案,但现在找不到它,并从我的“库”中发布:
@echo off setlocal EnableDelayedExpansion ::Identify OS for /F "delims=" %%a in ('ver') do set ver=%%a set Version= for %%a in (95=95 98=98 ME=ME NT=NT 2000=2000 5.1.=XP 5.2.=2003 6.0.=Vista 6.1.=7 6.2.=8) do ( if "!Version!" equ "this" ( set Version=Windows %%a ) else if "!ver: %%a=!" neq "%ver%" ( set Version=this ) ) ::Identify bit if exist "%SYSTEMDRIVE%\Program Files (x86)" ( set Type=64 bit ) else ( set Type=32 bit ) ::Display result echo %Version% %Type% goto :eof ::Goto right version goto %Version: =_% :Windows_8 echo Windows 8 :Windows_7 echo Windows 7
© Aacini at dostips
只需从命令行或批处理文件使用WMIC
。 更容易,更短,你可以解析它。
wmic OS get OSArchitecture,caption