I have written nsis script for java project.I have Batch file in my project.I have written batch file for commonly windows 32bit and 64 bit.After installing i have started batch file automatically using Exec command.Its woks fine in 32bit windows.but the same time this is not worked well in 64 bit.so i suspect that before installing i should check whether windows is 32 bit or 64 bit version.please share your views how to check?
Asked
Active
Viewed 2.5k times
35
-
Not worded as a duplicate question, but its the same: [use-one-nsis-installer-to-install-32-bit-binaries-on-32-bit-os-and-64-bit-binari](http://stackoverflow.com/questions/11126629/use-one-nsis-installer-to-install-32-bit-binaries-on-32-bit-os-and-64-bit-binari) – nawfal Jul 23 '13 at 08:57
3 Answers
65
For future lazy googlers - A small snippet:
Include this:
!include x64.nsh
And use this if:
${If} ${RunningX64}
# 64 bit code
${Else}
# 32 bit code
${EndIf}

Nitay
- 4,193
- 6
- 33
- 42
-
Does this detect all 64-bit architectures or just windows xp x64? – Jon Weinraub Oct 29 '14 at 18:47
-
I couldn't find a definite answer, I always assumed it does! I've tested it on Windows 7 64bit and Windows XP 64 bit and it worked. I never had any trouble with it on any Windows platform – Nitay Oct 30 '14 at 18:48
-
1It applies to all 64-bit versions of Windows. (It calls IsWow64Process internally) – Anders Nov 19 '14 at 16:03
39
Use the RunningX64 macro in the x64.nsh header:
!include LogicLib.nsh
!include x64.nsh
Section
${If} ${RunningX64}
DetailPrint "64-bit Windows"
${Else}
DetailPrint "32-bit Windows"
${EndIf}
SectionEnd

Anders
- 97,548
- 12
- 110
- 164
-
Thanks.In that url said ; File some.dll # extracts to C:\Windows\System32. what is some.dll? which file it mean to?. i could not able to understand – Ami Nov 06 '12 at 03:45
-
1oh thanks.that {If} part where am i put in my script? .oninit()? or some other place? – Ami Nov 06 '12 at 05:21
1
Here's what I use most of the time without the need for x64.nsh
Var Bit
System::Call "kernel32::GetCurrentProcess()i.s"
System::Call "kernel32::IsWow64Process(is,*i.r0)"
StrCmpS $0 0 +3
StrCpy $Bit 64
Goto +2
StrCpy $Bit 32
Now $Bit holds either 64 or 32 which can be used like this:
${If} $Bit == 64
...64-bit code..
${Else}
..32-bit code...
${EndIf}
Or
StrCmpS $Bit 64 SixtyFour ThirtyTwo
SixtyFour:
...
Goto End
ThirtyTwo:
...
End:
I used StrCmpS
as I believe it's a hair faster. Lol. Hope this helps! =)

daemon.devin
- 128
- 1
- 5