bat批处理判断系统32位或64位以及操作系统类型

时间:2021-03-13 09:04:32

方法一:
systeminfo |find "x64" 
方法二:
有时候需考虑wow的情况 


IF PROCESSOR_ARCHITECTURE == amd64 or 
   PROCESSOR_ARCHITEW6432 == amd64 THEN 
   // OS is 64bit 
ELSE 
   // OS is 32bit 
END IF 

Another way to test for the same thing is: 

IF PROCESSOR_ARCHITECTURE == x86 AND 
   PROCESSOR_ARCHITEW6432 NOT DEFINED THEN 
   // OS is 32bit 
ELSE 
   // OS is 64bit 

END IF


var中存储的数据,PROCESSOR_ARCHITECTURE存储的内容

@echo off
for /f "tokens=1* delims=[" %%a in ('ver') do set b=%%b
set b=%b:* =%
goto %b:~0,4%%PROCESSOR_ARCHITECTURE:~-1%
:5.1.6
echo xp_32位
goto:eof

:6.1.6
echo win7_32位
goto:eof
:6.1.4
echo win7_64位

:6.0.6
echo vista_32
exit

:6.0.4
echo vista_64
exit