windows - 如何在 32 位批处理脚本中运行 64 位版本的 Windows 实用程序(例如 msiexec)?

标签 windows batch-file windows-installer win64

我有一个批处理文件(出于兼容性原因)在 32 位 cmd.exe 进程中运行。但是,我现在需要启动 64 位版本的 Windows 命令行工具,在本例中为 msiexec。我该怎么做?

其他详细信息:

我正在使用批处理文件来安装各种软件产品。为了最大程度地兼容旧产品,批处理文件作为 32 位进程运行。但是,我现在需要安装 Intel Haxm,它需要 64 位版本的 msiexec

我已经尝试调用 c:\windows\system32\msiexec.exe,但是执行此操作时 Windows 安装程序日志文件仍然显示:

=== Verbose logging started: 14.04.2015 14:27:53 Build type: SHIP UNICODE 5.00.9600.00 Calling process: c:\windows\SysWOW64\msiexec.exe ===

最佳答案

您可以使用 sysnative 别名执行此操作,如 MSDN 文章 File System Redirector 中所述:

32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a special alias used to indicate that the file system should not redirect the access. This mechanism is flexible and easy to use, therefore, it is the recommended mechanism to bypass file system redirection. Note that 64-bit applications cannot use the Sysnative alias as it is a virtual directory not a real one.

Windows Server 2003 and Windows XP: The Sysnative alias was added starting with Windows Vista.

所以,在批处理文件中,你会这样说

%windir%\sysnative\msiexec /install product.msi /passive /norestart

或者如果您需要运行另一个批处理文件

%windir%\sysnative\cmd.exe /c silent_install.bat

请注意,除非安装了修补程序 942589,否则 64 位版本的 Windows XP 或 Windows 2003 不支持 sysnativeSee this answer for one workaround.

关于windows - 如何在 32 位批处理脚本中运行 64 位版本的 Windows 实用程序(例如 msiexec)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29627904/

相关文章:

windows-installer - 在 linux 中打开 MSI 文件的方法有哪些?

c - 为什么我不能在 Windows 套接字上禁用 MTU 发现? IP_PMTUDISC_DONT 设置失败

windows - 如何在不关闭命令提示符窗口的情况下返回错误代码?

java - 使用java依次执行多个批处理文件

java - 批处理文件在执行 Java 程序后立即终止(如果从另一个 Java 程序调用批处理文件)

windows - 使用批处理脚本检查环境中是否存在 JAVA_HOME

powershell - 从 Powershell 运行 cmd 文件时,无法安装 [名称] MsiExec 返回 : 255,

wix安装包中的二进制文件

c# - 覆盖系统快捷键

相当于 "echo -n"的 Windows 不再适用于 Win7