简体   繁体   English

NSIS安装程序的完成页面中.bat文件执行的混乱行为

[英]Confusing behavior of the .bat file execution from the finish page of NSIS installer

I'd like to let user to execute the installed application via a .bat file from the installation finish page. 我想让用户通过安装完成页面上的.bat文件执行已安装的应用程序。 That's the code: 那是代码:

!define INSTALL_DIR $PROGRAMFILES64\\(some folder) !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" Function LaunchLink SetOutPath "${INSTALL_DIR}" ExpandEnvStrings $0 %COMSPEC% Exec '"$0" /C "${INSTALL_DIR}\\my.bat"' FunctionEnd

It works as expected in most cases. 在大多数情况下,它可以按预期工作。 But in case I have both: 但万一我同时拥有:
C:\\Program Files\\(some folder) and C:\\ Program Files \\(某些文件夹)
C:\\Program Files (x86)\\(some folder) C:\\ Program Files(x86)\\(某些文件夹)
With my.bat file available in both of them, I get the one in the Program Files (x86) executed. 有了my.bat文件,它们在执行的程序文件(x86)中得到了一个。 I also tried to hardcode exact path to the .bat file instead of using ${INSTALL_DIR} constant, but still the same issue. 我也尝试过硬编码.bat文件的确切路径,而不是使用$ {INSTALL_DIR}常量,但是仍然存在相同的问题。

What am I doing wrong? 我究竟做错了什么? Am I missing something? 我想念什么吗?

You could check whether the system is x32 or x64 in your bat file and if you are on a x64 system delegate a call to the x32 file to the x64 file: 您可以检查bat文件中的系统是x32还是x64,并且如果您在x64系统上,则将对x32文件的调用委托给x64文件:

IF %PROCESSOR_ARCHITECTURE% == x86
(
    START "" C:\pathto\x86version.exe
) ELSE (
    START "" C:\pathto\x64version.exe
)

%PROCESSOR_ARCHITECTURE% is a system variable. %PROCESSOR_ARCHITECTURE%是系统变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM