Search code examples
installation32bit-64bitnsis

Merge 32bit and 64bit installer into one installer using NSIS


I have created a simple installer using NSIS. I want that the installer should detect the OS that a client is using.If a client is using a 32-bit OS then all the files should be copied to Program Files(32 bit) folder or else if he/she is using a 64-bit OS, all the files should be copied to 64-bit.Can anyone help me how to figure this out..

Thanks


Solution

  • Same as above (don't forget to include LogicLib.nsh and x64.nsh)

    Function .onInit
    
        ${If} ${RunningX64}
            StrCpy $INSTDIR "$PROGRAMFILES64\myProduct"
        ${Else}
            StrCpy $INSTDIR "$PROGRAMFILES\myProduct" ; $PROGRAMFILES32 also works
        ${EndIf}
    
    FunctionEnd
    

    Optionally, you can also set the registry view (see SetRegView)