Archive: install in programx86 or programx64


install in programx86 or programx64
  Hello,
his there a solution to do this :

${If} ${RunningX64} = true
!define PRODUCT_PATH "$PROGRAMFILES\Mysoftware\${PRODUCT_NAME_EXE}"
${Else}
!define PRODUCT_PATH "$PROGRAMFILES64\Mysoftware\${PRODUCT_NAME_EXE}"
${EndIf}


My executable is created for anyCPU and I search to install on $PROGRAMFILES64 when the windows is x64.. ;)

thanks for some help
christophe

This code is wrong on so many levels, I don't even know where to start!

!define is compile time, ${If} is runtime, you can't mix and match like this.

This is probably what you want:


"FooBarBaz.exe"


>!include x64.nsh
>Function .onInit
>${If} ${RunningX64}
>StrCpy $InstDir "$PROGRAMFILES64\Mysoftware"
>${Else}
>StrCpy $InstDir "$PROGRAMFILES\Mysoftware"
>${EndIf}
>FunctionEnd

>...

>Section
SetOutPath $instdir
File "c:\mystuff\${PRODUCT_NAME_EXE}"

>CreateShortcut "$smprograms\Mysoftware.lnk" "$instdir\${PRODUCT_NAME_EXE}"
>SectionEnd
>

Oh ! it's great! Thank you very much for your help, it works perfectly!


If you're extracting a 32-bit executable for both platforms you should be putting it in Program Files (x86) on 64-bit machines. Either way, you can just use $PROGRAMFILES64 which I'm fairly sure will be set to the same as $PROGRAMFILES on a 32-bit machine (although you should check this - the docs do not mention anything).

Stu


Originally posted by Afrow UK
If you're extracting a 32-bit executable for both platforms you should be putting it in Program Files (x86) on 64-bit machines.
He said anyCPU

Originally posted by Afrow UK
Either way, you can just use $PROGRAMFILES64 which I'm fairly sure will be set to the same as $PROGRAMFILES on a 32-bit machine (although you should check this - the docs do not mention anything).
Yes, in the current implementation $programfiles64 does fall back to $programfiles. This is not documented but since some of the shell constants also have fallback values I would not expect this feature to go away any time soon.

(And $programfiles/$programfiles32 falls back to c:\programfiles, which is IMHO broken behavior, but the whole programfiles lookup code uses a incorrect method so (The correct SHGetFolder function is used for the other constants so I'm guessing there is a reason))