문제

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

도움이 되었습니까?

해결책

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)

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top