NSIS脚本未安装在正确的目录中

NSIS脚本未安装在正确的目录中,nsis,system32,syswow64,Nsis,System32,Syswow64,我正在尝试制作一个安装脚本: 在32位pc上:在C:\windows\system32 在64位pc上:在C:\Windows\System32中的tapi_64bits.tsp和C:\Windows\SysWOW64中的tapi_32bits.tsp 这是我写的剧本: ; The name of the installer Name "TAPI Installer" ; The file to write OutFile "TAPI Installer" ; The default i

我正在尝试制作一个安装脚本:

  • 在32位pc上:在
    C:\windows\system32
  • 在64位pc上:在
    C:\Windows\System32
    中的tapi_64bits.tsp和
    C:\Windows\SysWOW64
    中的tapi_32bits.tsp
这是我写的剧本:

; 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
;--------------------------------

但在64位pc上,它将两个文件(tapi_64bits.tsp和tapi_32bits.tsp)都放在Syswow64文件夹中。安装程序确实说它安装在正确的文件夹中,但这两个文件都在Syswow64文件夹中。我做错了什么

NSIS是一个32位的应用程序,因此受以下因素的影响


您必须使用,它有代码来检测WOW64并禁用重定向(尽快将其重新打开)。另一种选择是提取到
$windir\sysnative
,但这更像是一种黑客行为,在XP 64上不起作用。

NSIS是一个32位应用程序,因此它会受到影响


您必须使用,它有代码来检测WOW64并禁用重定向(尽快将其重新打开)。另一种选择是提取到
$windir\sysnative
,但这更像是一种黑客行为,在XP 64上不起作用。

以下代码应该可以工作

!include x64.nsh    
; Install to the correct directory on 32 bit or 64 bit machines
Section
${If} ${RunningX64}
; 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
${Else}
; Set output path to the installation directory.
SetOutPath $SYSDIR
; Put file there
File tapi_32bits.tsp
${EndIf}
SectionEnd

下面的代码应该可以工作

!include x64.nsh    
; Install to the correct directory on 32 bit or 64 bit machines
Section
${If} ${RunningX64}
; 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
${Else}
; Set output path to the installation directory.
SetOutPath $SYSDIR
; Put file there
File tapi_32bits.tsp
${EndIf}
SectionEnd

似乎ok在Win 7上sysnative被system32取代x64@Tanguy:不,不是!在64位应用程序中,只有%windir%\system32,其中包含真正的64位系统文件(32位系统文件位于SysWow64中)。在32位应用程序中,%windir%\sysnative包含64位系统文件,%windir%\system32包含32位系统文件…在使用nsis 32位设置的64位系统上,使用输出路径为
$SYSDIR
DisableX64FSRedirection
-将我的64位dll放置在共享dll的正确目录中-jsut需要检查共享计数器,如果它事先已经存在,则不需要替换它?@PatrickArtner库头可以为您执行共享计数器和64位内容。似乎可以sysnative在Win 7上被system32取代x64@Tanguy:不,不是!在64位应用程序中,只有%windir%\system32,其中包含真正的64位系统文件(32位系统文件位于SysWow64中)。在32位应用程序中,%windir%\sysnative包含64位系统文件,%windir%\system32包含32位系统文件…在使用nsis 32位设置的64位系统上,使用输出路径为
$SYSDIR
DisableX64FSRedirection
,将把我的64位dll放在共享dll的正确目录中-jsut需要检查共享计数器,如果它事先已经存在,就不需要替换它了?@PatrickArtner库头可以为您做共享计数器和64位的事情。