Question

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

Was it helpful?

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)

OTHER TIPS

Following code will do the task.

!include "x64.nsh"
.
.
.
.
var copyDir

section ""

${If} ${RunningX64}
strcpy $copyDir "C:\\Program Files(x64)\\Foo"

${else}
strcpy $copyDir "C:\\Program Files\\Foo"
sectionend

Although if its just about detecting the Program Files directory, I think $ProgramFiles will automatically detect the default Program Files directory according to the OS bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top