2010-04-05 97 views
2

我想使用NSIS安裝程序將war文件複製到tomcat web-app目錄。使用下面的腳本如何使用NSIS複製文件?

!define PRODUCT_NAME "App Deploy" 
!define PRODUCT_VERSION "1.0" 
!define PRODUCT_PUBLISHER "ZippySoft" 

SetCompressor lzma 

;!include "UserManagement.nsh" 


; MUI 1.67 compatible ------ 
!include "MUI.nsh" 

; MUI Settings 
!define MUI_ABORTWARNING 
;!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" 

; Welcome page 
!insertmacro MUI_PAGE_WELCOME 
; Components page 
!insertmacro MUI_PAGE_COMPONENTS 
; Instfiles page 
!insertmacro MUI_PAGE_INSTFILES 
; Finish page 
!insertmacro MUI_PAGE_FINISH 

; Language files 
!insertmacro MUI_LANGUAGE "English" 

; Reserve files 
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS 

; MUI end ------ 

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" 
OutFile "AppDeploy.exe" 
InstallDir "$PROGRAMFILES\App Deploy" 
ShowInstDetails show 

;Section -SETTINGS 
; SetOutPath "$INSTDIR" 
; SetOverwrite ifnewer 
;SectionEnd 

;Section "JDK" SEC01 
; File "Prerequisites\jdk-1_5_0_15-windows-i586-p.exe" 
; ExecWait "$INSTDIR\jdk-1_5_0_15-windows-i586-p.exe" 
;SectionEnd 

;System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("name", "value").r0' 
;StrCmp $0 0 error 
; ExecWait ProgThatReadsEnv.exe 
; Goto done 
;error: 
; MessageBox MB_OK "Can't set environment variable" 
;done: 

;Section "Tomcat" SEC02 
; File "Prerequisites\apache-tomcat-6.0.16.exe" 
; ExecWait "$INSTDIR\apache-tomcat-6.0.16.exe" 
;SectionEnd 

Section "Data Submission Tool" SEC03 
    File "Prerequisites\DataSubmissionToolFinal.war" 
    CopyFiles `$INSTDIR\DataSubmissionToolFinal.war` `c:\DataSubmissionToolFinal.war` 
    StrCpy $0 "$INSTDIR\DataSubmissionToolFinal.war" ;Path of copy file from 
    StrCpy $1 "c:\DataSubmissionToolFinal.war" ;Path of copy file to 
    StrCpy $2 1 ; only 0 or 1, set 0 to overwrite file if it already exists 
    System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l' 
    Pop $0 ; pops a bool. if overwrite is off and there is a file then error will be 1 
SectionEnd 

沒有腳本錯誤,但戰爭的文件沒有得到複製到c驅動我已經成功安裝Tomcat和JDK。怎麼做?還有可能使用NSIS來識別JDK和Tomcat安裝的路徑嗎?

很抱歉,如果這個問題太明顯了,我很新的NSIS ..

回答

5

嘗試

File /oname=c:\DataSubmissionToolFinal.war DataSubmissionToolFinal.war 
+0

@Robert,這就是正確的,我不知道爲什麼OP需要在C提取:\雖然。 – YOU 2010-04-05 13:03:17

+0

這兩個路徑都應該使用單獨的引號,如File /oname="c:\DataSubmissionToolFinal.war「」DataSubmissionToolFinal.war「?? – fayyazkl 2012-12-18 13:51:20