简体   繁体   中英

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. 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 (x86)\\(some folder)
With my.bat file available in both of them, I get the one in the Program Files (x86) executed. I also tried to hardcode exact path to the .bat file instead of using ${INSTALL_DIR} constant, but still the same issue.

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:

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

%PROCESSOR_ARCHITECTURE% is a system variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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