2012-05-25 34 views
0

不安装,我试图让安装脚本:在32位PCNSIS脚本在正确的目录

  • :tapi_32bits.tsp在C:\windows\system32
  • 在64位PC:tapi_64bits.tsp在C:\Windows\System32和tapi_32bits.tsp在C:\Windows\SysWOW64

这是我写的剧本:

; 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文件夹中。我究竟做错了什么?

回答

3

NSIS是一个32位应用程序,以便它是由file redirection影响。

必须使用x64.nsh,它的代码来检测WOW64和禁用重定向(重新打开它尽快)。另一种方法是解压到$windir\sysnative但更多的是黑客和XP 64

+0

似乎确定sysnative被替换SYSTEM32在Win 7 X64的 – Tanguy

+0

@Tanguy:不,它不是!在64位应用程序中,只有%windir%\ system32,它包含真正的64位系统文件(32位系统文件位于SysWow64中)。在32位应用程序中,%windir%\ sysnative包含64位系统文件,%windir%\ system32包含32位系统文件... – Anders

-1

下面的代码应该工作不起作用。

!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