Archive: How do I store a resource file in setup


How do I store a resource file in setup
I am creating an installer for deploying a web application on server.

Here is a script

!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


But for some reason DataSubmissionToolFinal.war file is not getting copied to c:\

which I am specifying at line

File "Prerequisites\DataSubmissionToolFinal.war"
CopyFiles `$INSTDIR\DataSubmissionToolFinal.war` `c:\DataSubmissionToolFinal.war
`

What is the exact procedure to copy file present in setup to some physical path (Just like XCopy)

thanks

There's a couple of things that might be going wrong there...

From the script as you have it pasted above...

1. In the "-Settings" section, you have your `; SetOutPath "$INSTDIR"` commented out. This means that $OUTDIR is null by the time the "Data Submission Tool" hits the File command is null/empty/nothing.

2. Are you sure that the file actually exists in the location "$INSTDIR\DataSubmissionToolFinal.war" before you try to copy the file? Use IfFileExists to make sure that your installer can see it there.

3. Are you sure that you, or rather your installer, can write to the C root? Under some accounts and some OS's - especially after a SysAdmin decides to lock things down - you can't write to the C (and/or boot drive) root.

If all the above checks out, then the code as you have it should be fine. I would comment out the system call just so you can work on one problem at a time (and I suppose it would really just duplicate the behavior of CopyFiles anyway?)