"Error opening file for writing:"
Hello,
I have searched for the answer to this problem and have had NO luck so far. Please forgive me if I have overlooked the solution, but I am officially at a loss and don't understand the breakdown- I'm hoping someone here can shed some light on the problem.
I have created an installer that was working flawlessly. However, I have started working on creating my User Guide which will have screen shots of the install which has me doing a fresh install on my test machine. I get the installer compiled and run it, which starts off fine. The problem comes when it starts writing files to disk. Apparently there is something causing (a breakdown with permissions presumably) because I get the following:
Error opening file for writing:
C:\Program Files\MyCompany\MyApp\settings
Click Abort to stop the installation,
Retry to try again, or
Ignore to skip this file.
When I skip the file, it gives the same error for the next (and each subsequent file) in the instructions.
HOW can this be overcome? What have I done wrong in building my script? Please help me understand the error, how to overcome it, and how to prevent these problems in the future.
Any input or advice is appreciated.
Here is my file:
; MyApp_installer.nsi
;
; This script is used to install My Application version 1.5.5
;--------------------------------
; includes
; banner
!include "WinMessages.nsh"
; The name of the installer
Name "MyApp 1.5x"
; The file to write
OutFile "myApp1_5_5_setup.exe"
; Define License file
LicenseData "eula.txt"
; The default installation directory
InstallDir $PROGRAMFILES\MyCompany\MyApp
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\MyApp" "Install_Dir"
; Request application privileges for Windows Vista
RequestExecutionLevel admin
;--------------------------------
; Pages
;!insertmacro MUI_PAGE_LICENSE "eula.txt"
Page License
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; The stuff to install
Section "MyApp Binary/Configs" ;No components page, name is not important
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File eula.txt
File settings
File start_MyApp.bat
File stop_MyApp.bat
File MyApp.exe
File ServiceConfig.exe
File /r 'MyApp Libs'
File /r 'ServiceConfig Libs'
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "DisplayName" "MyApp"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "NoRepair" 1
WriteUninstaller "uninstall.exe"
CreateDirectory "$SMPROGRAMS\MyCompany\MyApp"
CreateShortCut "$SMPROGRAMS\MyCompany\MyApp\ServiceConfig.lnk" "$INSTDIR\ServiceConfig.exe" "" "$INSTDIR\ServiceConfig.exe" 0
CreateShortCut "$SMPROGRAMS\MyCompany\MyApp\start_MyApp.lnk" "$INSTDIR\start_MyApp.bat" "" "$INSTDIR\start_MyApp.bat" 0
CreateShortCut "$SMPROGRAMS\MyCompany\MyApp\stop_MyApp.lnk" "$INSTDIR\stop_MyApp.bat" "" "$INSTDIR\stop_MyApp.bat" 0
CreateShortCut "$SMPROGRAMS\MyCompany\MyApp\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
SectionEnd ; end the section
Section "Install as service"
nsSCM::Install /NOUNLOAD "MyApp" "MyApp" 16 2 $INSTDIR\MyApp.exe "" "" "" ""
Pop $0 ; return error/success
SectionEnd
Section "Uninstall"
;stop and remove service
nsSCM::Stop "MyApp"
nsSCM::Remove "MyApp"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp"
DeleteRegKey HKLM SOFTWARE\MyApp
; Remove files and uninstaller
Delete $INSTDIR\uninstall.exe
Delete $INSTDIR\settings
Delete $INSTDIR\start_MyApp.bat
Delete $INSTDIR\stop_MyApp.bat
Delete $INSTDIR\MyApp.exe
Delete $INSTDIR\ServiceConfig.exe
Delete $INSTDIR\eula.txt
Delete "$INSTDIR\MyApp Libs\*.*"
Delete "$INSTDIR\ServiceConfig Libs\*.*"
; Remove shortcuts, if any
Delete "$SMPROGRAMS\MyCompany\MyApp\*.*"
; Remove directories used
RMDir "$INSTDIR\MyApp Libs\"
RMDir "$INSTDIR\ServiceConfig Libs\*.*"
RMDir "$INSTDIR"
RMDir "$SMPROGRAMS\MyCompany\MyApp\"
SectionEnd
Section "Start MyApp Service"
Exec '"$INSTDIR\start_MyApp.bat"'
SectionEnd