Skip to content
⌘ NSIS Forum Archive

One installer for 32bit and 64bit

12 posts

voyteckst#

One installer for 32bit and 64bit

I'm creating installer which will contain components for 32 and 64 bit systems. There is no problem with copying correct files, but I don't know how to define INSTDIR and InstallDir. Can someone tell me how to set INSTDIR and InstallDir depending on Windows architecture (i.e. in .oninit)?
MSG#
You want to use x64.nsh. (This question has been asked dozens of times before. Please search before you ask.)
MSG#
InstallDir is a compiletime command. If you're setting $INSTDIR in .onInit anyway, using it is pointless.

This is probably all you have to do:

funtion .onInit
${If} ${RunningX64}
StrCpy $INSTDIR "Your x64 default install path"
$[Else}
StrCpy $INSTDIR "Your x86 default install path"
${EndIf}
FunctionEnd
voyteckst#
Thanks. But should it be in .oninit or can be in other function which I have (also it is question for sysdir) - I give 64bit user page where he have choice to install 32bit or either 64bit version. Choice is because it installs some component for browsers and because i.e. firefox officially is not 64bit (and user likes to use ff) he can install 32bit version.
Afrow UK#
If it is system32/syswow64 then you don't need to change the actual value of $INSTDIR and just use the DisableX64FSRedirection/EnableX64FSRedirection macros from x64.nsh. For other paths not dependent on x64 file system redirection then you need to change $OUTDIR (SetOutPath) accordingly. And no it doesn't need to be in .onInit - if you do change $INSTDIR it needs to be before the Directory page of course (if you are using it).

Stu
voyteckst#
Thanks it works fine, but I have to manually set DisableX64FSRedirection/EnableX64FSRedirection each time I want to copy something to $SYSDIR. It don't works when set in .oninit.
Animaether#
Should be fine in .onInit unless something else messes with the x64 redirection under your installer process.

just as an aside.. on Vista and above, and XP with a particular by-request hotfix (so I wouldn't depend on it), you can also write to the special SysNative folder, which is the 64bit System folder on 64bit platforms, and simply doesn't exist on 32bit platforms.
The windir \\System32 directory is reserved for 64-bit applications on 64-bit Windows.
voyteckst#
I have strange issue. When user choose whether to install 32 or 64 bit i set variable named arch and based on it I'm copying 32 or 64 bit files. But it works on one test computer and on other two not... What can be wrong? Code for this is below:

SetOutPath $SYSDIR
${If} $arch == 32
File "file.dll"
${ElseIf} $arch == 64
${DisableX64FSRedirection}
File /oname=file.dll "filex64.dll"
${Else}
${EndIf}
redxii#
What exactly is it doing or not doing (copying wrong file/wrong location/etc)? I would write it like this:

  SetOutPath "$SYSDIR"
 
  {If} $arch == 32
    File "file.dll"
  ${ElseIf} $arch == 64
    ${DisableX64FSRedirection}
    File /oname=file.dll "filex64.dll"
    ${EnableX64FSRedirection}
  ${EndIf} 
voyteckst#edited
It doesn't copy this file. I will try to make different functions for 32 and 64 and call them according to arch variable.

What is the purpose of running at the and ${EnableX64FSRedirection} ?

Edit: Different functions and calling them according to this variable works ok.
MSG#
Originally Posted by voyteckst View Post
What is the purpose of running at the and ${EnableX64FSRedirection} ?
It's to return the installer to standard behavior. In case you forget later on that you changed it. It's good practice to always do this.