首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSIS脚本没有安装在正确的目录中

NSIS脚本没有安装在正确的目录中
EN

Stack Overflow用户
提问于 2012-05-25 13:32:18
回答 2查看 5.9K关注 0票数 1

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

  • 32位pc: tapi_32bits.tsp在C:\windows\system32上的应用
  • 64位pc:C:\Windows\System32中的C:\Windows\System32C:\Windows\SysWOW64中的tapi_32bits.tsp

这就是我写的剧本:

代码语言:javascript
复制
; 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文件夹中。我做错了什么?

EN

回答 2

Stack Overflow用户

发布于 2012-05-25 20:06:02

NSIS是一个32位的应用程序,因此受到文件重定向的影响。

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

票数 5
EN

Stack Overflow用户

发布于 2014-04-01 17:09:17

下面的代码应该可以工作。

代码语言:javascript
复制
!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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10755338

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档