winrar选择自动64位或32位

问题描述 投票:-1回答:2

我想创建自动解压缩winrar,用开关自动安装软件我有2个版本64和32位,并希望winrar由系统选择怎么做?

winrar
2个回答
0
投票

假设您使用的是Windows,则可以使用以下行创建批处理脚本:

reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | 
find /i "x86" > NUL && set OS=32BIT || set OS=64BIT

if %OS%==32BIT 
@Extract the 32 bit version here
if %OS%==64BIT
@Extract the 64 bit version here

0
投票

首先,您需要知道计算机中的处理器具有哪种架构并不重要。它只与运行Windows使用的架构有关。可以在具有64位处理器的计算机上安装和使用32位Windows,尽管很少这样做。

其次,对于64位Windows,你需要知道WOW64 Implementation DetailsFile System RedirectorRegistry Keys Affected by WOW64

第三,32位和64位Windows(amd64,而不是ia64)的RAR自解压存档必须是x86 SFX存档。这意味着提取后执行的批处理文件由64位Windows上的32位cmd.exe处理。在阅读有关WOW64实现细节的Microsoft文章之后,应该清楚如何在64位Windows上的32位环境中运行批处理文件,以访问环境变量,文件系统和Windows注册表。

名为ProgramFiles(x86)的环境变量仅存在于32位和64位环境中的64位Windows上。此事实可用于检测批处理文件是否在具有32位或64位Windows的计算机上执行。

if "%ProgramFiles(x86)%" == "" goto Win32
rem Commands to install amd64 version of the application.
goto :EOF

:Win32
rem Commands to install x86 version of the application.

另请参阅现有的Stack Overflow问题:

© www.soinside.com 2019 - 2024. All rights reserved.