1

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?

archie_by
  • 1,623
  • 2
  • 11
  • 10
  • If you change the /C to /K you can inspect the commandline of cmd.exe in Process Explorer. Is NSIS passing the correct path to your batch file? – Anders Mar 27 '15 at 13:46

1 Answers1

0

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.

MichaelS
  • 5,941
  • 6
  • 31
  • 46
  • Thanks for your reply, but the goal is to prevent wrong .bat from being executed, not to add some workaround to the wrong .bat – archie_by Mar 27 '15 at 11:34