In 64 bit operating system, for the portable app with both 32 bit and 64 bit exe, e.g. 7-Zip Portable, If you delete the 7-Zip64\7zFM.exe
(the 64 bit executable file of 7-Zip), You will receive a ERROR message "7-Zip Portable cannot be started. You may wish to re-install to fix this issue. (ERROR: App\7-Zip64\7zFM.exe could not be found)", this is because PAL will set the execute path to the path of 64-bit exe if it is stated in [Launch]:ProgramExecutable64
of the launcher file, but it didn't test whether the file in ProgramExecutable64 exist or not.
The solution is insert the file test before setting the string as the executable path of the program.
The following is the part of Core.nsh
that had been modified to fix this problem.
...
${GetParameters} $0
StrCpy $ProgramExecutable ""
${If} $Bits = 64
${If} $0 != ""
${ReadLauncherConfig} $1 Launch ProgramExecutableWhenParameters64
${If} ${FileExists} $1
StrCpy $ProgramExecutable $1
${EndIf}
${EndIf}
${If} $ProgramExecutable == ""
${ReadLauncherConfig} $1 Launch ProgramExecutable64
${If} ${FileExists} $1
StrCpy $ProgramExecutable $1
${EndIf}
${EndIf}
${EndIf}
${If} $0 != ""
${AndIf} $ProgramExecutable == ""
${ReadLauncherConfig} $1 Launch ProgramExecutableWhenParameters
${If} ${FileExists} $1
StrCpy $ProgramExecutable $1
${EndIf}
${EndIf}
${If} $ProgramExecutable == ""
${ReadLauncherConfig} $1 Launch ProgramExecutable
${If} ${FileExists} $1
StrCpy $ProgramExecutable $1
${EndIf}
${EndIf}
${If} $ProgramExecutable == ""
; Launcher file missing or missing crucial details (what am I to launch?)
MessageBox MB_OK|MB_ICONSTOP `$EXEDIR\App\AppInfo\Launcher\$BaseName.ini is missing [Launch]:ProgramExecutable - what am I to launch?`
Quit
${EndIf}
...
In addition, this means that the environment variable FullAppDir
handled by the Custom.nsh
in some applications needs to be modified and fixed, e.g. 7-Zip Portable, AkelPad Portable, Avidemux Portable etc. The following is my fix:
${If} $Bits = 64
${AndIf} ${FileExists} "$EXEDIR\App\AppName64\AppName.exe"
${SetEnvironmentVariablesPath} FullAppDir "$EXEDIR\App\AppName64"
${Else}
${SetEnvironmentVariablesPath} FullAppDir "$EXEDIR\App\AppName"
${EndIf}
The same bug was also mentioned in my another post discussing PAL coding convention. If you have any thoughts on PAL coding convention, I hope you can share it on that post.
This is not a bug. If it is set to exist, it should exist. At some point we will be making a feature enhancement to allow install of either/or 32/64-bit and update the launcher to handle the nonexistence of either.
Sometimes, the impossible can become possible, if you're awesome!