phi*_*lip 17 shell batch-file 32bit-64bit
有没有人知道如何创建一个批处理文件,如果它是一个64位系统,可以shell一个程序,如果它是一个32位系统,那么它是另一个程序?
Joe*_*oey 23
检查%PROCESSOR_ARCHITECTURE%是x86:
if %PROCESSOR_ARCHITECTURE%==x86 (
rem 32 bit
) else (
rem 64 bit
)
Run Code Online (Sandbox Code Playgroud)
至少目前是这样.例如,在服务器上我可以访问它,AMD64但不知道Itanium的样子.但32位版本总是报告x86.
另一种选择,也适用于WoW64:
for /f "skip=1 delims=" %%x in ('wmic cpu get addresswidth') do if not defined AddressWidth set AddressWidth=%%x
if %AddressWidth%==64 (
rem 64 bit
) else (
rem 32 bit
)
Run Code Online (Sandbox Code Playgroud)
Jos*_*sef 12
它没有WMI也可以工作!我建议:
@echo off
if /i "%processor_architecture%"=="AMD64" GOTO AMD64
if /i "%PROCESSOR_ARCHITEW6432%"=="AMD64" GOTO AMD64
if /i "%processor_architecture%"=="x86" GOTO x86
GOTO ERR
:AMD64
rem do amd64 stuff
GOTO EXEC
:x86
rem do x86 stuff
GOTO EXEC
:EXEC
rem do arch independent stuff
GOTO END
:ERR
@echo Unsupported architecture "%processor_architecture%"!
pause
:END
Run Code Online (Sandbox Code Playgroud)
uname -a #for mac
uname -i #for ubuntu
Run Code Online (Sandbox Code Playgroud)