I'm writing a installer for windows using nsis. This installer contains a web application which is run on top of xampp, so xampp is also installed as a service with this application. But xamp gives an issue when it installed in 64bit machine on Windows 7. This is due to the directory path issue in C:\Program Files (x86) as mentioned here.
XAMPP Error Solution? I have that installed on my Windows XP Dual Boot Machine
But currently the automatic installation path is set as follows in the installer.
C:\Program Files (x86)\myapplication
The installer script just have the following macro to add the directory chooser page.
!insertmacro MUI_PAGE_DIRECTORY
As a solution what I'm going to do are following actions.
For that I need to get the install directory path by
$INSTDIR
and
Since I'm not much familiar with nsis I'm unable to write this program.
Can someone help me on this issue?
NSIS provides $PROGRAMFILES32 and $PROGRAMFILES64:
InstallDir "$PROGRAMFILES64\myapp"
On a win7/64, the 64 bits program files can be get from a 32 bit application via the %ProgramW6432%
environment variable.
You could try to get it with ReadEnvStr
:
c:\program files
(if not configured elsewhere)Here is a snippet that test it :
ReadEnvStr $0 ProgramW6432
StrCmp $0 "" 0 +3
MessageBox MB_OK "it is a 32b system"
goto +2
MessageBox MB_OK "it is a 64b system"
In your case, it could do :
ReadEnvStr $0 ProgramW6432
StrCmp $0 "" +2 0
StrCpy $INSTDIR $0
Edit: For the point to refuse Program Files (x86)
you could use the .onVerifyInstDir
callback method that was given by Anders for another question, it will check the choosen directory as it is selected by the user and before changing the page :
Function .onVerifyInstDir
ReadEnvStr $0 "ProgramFiles(x86)"
StrCmp $0 $INSTDIR 0 PathGood
MessageBox MB_OK "directory not valid for installation"
Abort
PathGood:
FunctionEnd
Here, I use another environment variable to get the (x86) variant of program files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With