如果Processor = xx位,则批量执行此操作吗? [英] If Processor=xx-bit do this in batch?

查看:100
本文介绍了如果Processor = xx位,则批量执行此操作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写批处理脚本以执行特定程序,具体取决于系统的体系结构.例如,如下所示:

I'm trying to write a batch script to execute a certain program depending on the architecture of the system. For example, something like this:

If ProcessorArch=64-bit 7zip64.exe
If ProcessorArch=32-bit 7zip.exe
If ProcessorArch=x86-64-bit 7zipx86-64.exe

谢谢

推荐答案

环境变量PROCESSOR_ARCHITECTURE

  1. 在运行独立于CPU架构的32位Windows时始终 x86 ,即使在具有Intel/AMD x64处理器的主板上也可以安装并运行32位Windows而不是Windows x64和

  1. is always x86 on running 32-bit Windows independent on architecture of the CPU as even on a motherboard with an Intel/AMD x64 processor a 32-bit Windows can be installed and running instead of Windows x64 and

x86 AMD64 IA64 ,具体取决于

  • CPU和运行Windows的体系结构: AMD64 IA64
  • 当前正在运行的进程的体系结构: AMD64 IA64 x86
  • architecture of CPU and running Windows: AMD64 or IA64
  • architecture of currently running process: AMD64 or IA64 or x86


请参阅Microsoft文档页面:


See the Microsoft documentation pages:

  • WOW64 Implementation Details
  • File System Redirector
  • Registry Keys Affected by WOW64

使用批处理文件安装某些文件时,通常建议考虑Windows操作系统的体系结构,而不要考虑当前正在执行该批处理文件的命令进程的体系结构.

On using a batch file to install something it is in general advisable to take the architecture of the Windows operating system into account and not the architecture of the command process executing currently the batch file.

在运行只调用其他应用程序的批处理文件时,通常建议使用与当前进程使用相同的体系结构来运行该应用程序,这就是为什么环境变量PROCESSOR_ARCHITECTURE的值取决于64位Windows以及体系结构的原因的当前过程.

On running a batch file which just calls other applications it is usually advisable to run the application with same architecture as the current process uses which is the reason why value of environment variable PROCESSOR_ARCHITECTURE depends on 64-bit Windows also on architecture of current process.

适用于Windows的7-Zip 可作为x86或x64应用程序使用.没有"x86-64"据我所知版本.

7-Zip for Windows is available either as x86 or as x64 application. There is no "x86-64" version as far as I know.

可以使用的批处理代码为:

A batch code which could be used is:

if /I "%PROCESSOR_ARCHITECTURE%" == "x86"   goto Zip32
if /I "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto Zip64
echo ERROR: Processor architecture %PROCESSOR_ARCHITECTURE% is not supported.
echo/
pause
goto :EOF

:Zip32
if "%ProgramFiles(x86)%" == "" (
    echo Using 32-bit 7-Zip ...
) else (
    echo Using 32-bit 7-Zip on 64-bit Windows ...
)
rem The commands using 32-bit 7-Zip.
goto :EOF

:Zip64
echo Using 64-bit 7-Zip ...
rem The commands using 64-bit 7-Zip.

这篇关于如果Processor = xx位,则批量执行此操作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆