Reputation: 89
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
Upvotes: 2
Views: 2513
Reputation: 12882
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)
Upvotes: 2
Reputation: 2943
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.
Upvotes: 1