Archive: Issues with 32/64bit install creation!


Issues with 32/64bit install creation!
Hi,

I'm currently trying to write an install which will hopefully determine if the OS is 32bit or 64bit and install certain files into specific locations accordingly. Some of the files are driver/inf/cat files for installing a USB device, which is done by DPInst.

I'm having 2 issues which I would love help with. the 1st in the following code :
!include WinVer.nsh

Section "MainSection" SEC01
GetVersion::WindowsPlatformArchitecture
Pop $R0
DetailPrint "Detected a $R0 bit windows architecture"
!if "$R0" == "32"
InstallDir "$PROGRAMFILES\Blah\Jeans Drivers"
!else
InstallDir "$PROGRAMFILES\Blah\Jeans Drivers 32"
!endif
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
SectionEnd

but I get
Error: command InstallDir not valid in Section
Error in script : "C:\NSISSourceFiles\driver_script.nsi" on line 71 -- aborting creation process

This error seems to reflect back to the InstallDir after the !else line?!? (i.e. that's the line that turns red when I double click on the error)

Any suggestions??


1. You're confusing !if and ${If}.
2. Use !include x64.nsh and ${If} ${RunningX64} (no need for my plug-in).
3. Use StrCpy $INSTDIR. InstallDir is a compile time instruction and cannot be used in functions or sections.

Stu


I had thought that alright but I got an error from that too so changed it!

This is what I had initially...right up the top, before any "Section" heading...

${If} ${RunningX64}
InstallDir "$PROGRAMFILES64\Blah\Jeans Drivers"
${Else}
InstallDir "$PROGRAMFILES\Blah\Jeans Drivers"
${EndIf}

That gives...
Error in macro _RunningX64 on macroline 2
Error in macto _If on macroline 9
Error in script "C:\NSISSourceFiles\driver_script.nsi" on line 48 -- aborting creation process


You're missing the actual error.

Edit: You can't use LogicLib outside a function/section. It's for run time, not compile time! Use my 1-3 in my first post.

Stu


Sorry - and I'm not even blonde!! :)

the error is
Error: Can't add entry, no section or function is open!


Ok - I guess what I'm getting at is "Is there an easy way to determine what InstallDir should be at runtime? based on whether the user is running on a 32bit or 64bit machine?"

Thanks! :)


You can use StrCpy $instdir "$programfiles\foo\bar" in .onInit


Bingo!! Thanks!!


I already said that in my first post (minus the use of .onInit mind).

Stu


Thank you both! I have that part sorted! :)