Archive: One installer for 32bit and 64bit


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)?


You want to use x64.nsh. (This question has been asked dozens of times before. Please search before you ask.)


Yes, I have searched, but as far as I remember it doesn't worked for InstallDir?


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

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.


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


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.


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.
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx


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}

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}

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.


Originally posted by voyteckst
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.