Q:

NSIS script not installing in correct directory

I am trying to make an install script: 

on 32bits pc: tapi_32bits.tsp in C:\windows\system32
on 64bits pc : tapi_64bits.tsp in C:\Windows\System32 and tapi_32bits.tsp in C:\Windows\SysWOW64

This is the script I wrote:
; The name of the installer
Name "TAPI Installer"

; The file to write
OutFile "TAPI Installer"

; The default installation directory
InstallDir $DESKTOP

;--------------------------------

; Install to the correct directory on 32 bit or 64 bit machines
Section
IfFileExists $WINDIR\SYSWOW64\*.* Is64bit Is32bit
Is32bit:
    ; Set output path to the installation directory.
    SetOutPath $SYSDIR

    ; Put file there
    File tapi_32bits.tsp

;   SectionEnd MessageBox MB_OK "32 bit"
        SetRegView 32
        StrCpy $INSTDIR "$PROGRAMFILES32\LANDesk\Health Check"
    GOTO End32Bitvs64BitCheck

Is64bit:
    ; install in  C:\Windows\System32
    SetOutPath $WINDIR\System32\

    ; file to put there
    File tapi_64bits.tsp

    ; install in C:\Windows\SysWOW64
    SetOutPath $WINDIR\SysWOW64

    ; file to put there
    File tapi_32bits.tsp

    ;SectionEnd MessageBox MB_OK "32 bit"
        SetRegView 32
        StrCpy $INSTDIR "$PROGRAMFILES32\LANDesk\Health Check"
        GOTO End32Bitvs64BitCheck    
    MessageBox MB_OK "64 bit"
        SetRegView 64
        StrCpy $INSTDIR "$PROGRAMFILES64\LANDesk\Health Check"

End32Bitvs64BitCheck:
SectionEnd
;--------------------------------

But on 64bits pc it  places both files (tapi_64bits.tsp and tapi_32bits.tsp) in the Syswow64 folder. The installer does say that it is installed in the correct folder but both files are  in the Syswow64 folder. What am I doing wrong? 

A:

NSIS is a 32 bit application so it is affected by file redirection.
You must use x64.nsh, it has code to detect WOW64 and disable redirection (Turn it back on as soon as possible). The other alternative is to extract to $windir\sysnative but that is more of a hack and does not work on XP 64.

