Install/reinstall/uninstall
Hello kichik,
can you pleas help me with my code.
I heave serious problem with my code, can you pleas check te code and repair where neccecary.
The programm must control if the programm is alraedy installed, if yes then reinstalling or quit.
Thanks in advance
Peter.BE, sorry for the Engl.
; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "RapportBasis"
!define PRODUCT_VERSION "versie 1.5"
!define PRODUCT_PUBLISHER "De Beroepsschool Aalst"
!define PRODUCT_WEB_SITE "http://schoolweb.argo.be/ibso/aalst/start.htm"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "Sections.nsh"
InstType "/NOCUSTOM"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\962.bmp" ; optional
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Start menu page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${PRODUCT_NAME}"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "Dutch"
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_NAME}.exe"
BRANDINGTEXT "Rapportenbeheer voor de leerlingen van De Beroepsschool/ De Horizon, Aalst."
InstallDir "C:\${PRODUCT_NAME}"
ShowInstDetails show
ShowUnInstDetails show
;--------------------------------
Function .onVerifyInstDir
IfFileExists "$INSTDIR" Ask_Question
Goto UNINSTALL
Ask_Question:
MessageBox MB_YESNO "${PRODUCT_NAME} is al geïnstalleerd. \
Wil u het eerst verwjderen en vervolgens opnieuw installeren? \
Als u op Nee klikt moet u de installatie \
volledig annuleren en van de cd-rom een ander \
setup bestand selecteren dat nog \
niet is geïnstalleerd." \
IDYES UNINSTALL IDNO INSTALL
INSTALL:
QUIT
UNINSTALL:
ExecWait '"$INSTDIR\uninstall.exe"'
ExecWait '"$INSTDIR\Verwijderen.exe"'
FunctionEnd
;--------------------------------
Section "RAPPORTEN" SEC01
SetOutPath "$INSTDIR"
SetOverwrite off
File "C:\RapportBasis11\Nieuwe map\Rapporten.xls"
File "C:\RapportBasis11\Nieuwe map\Rapport.ico"
File "C:\RapportBasis11\Nieuwe map\Explorer.ico"
; Shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
SetOverwrite off
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Start ${PRODUCT_NAME}.lnk" "$INSTDIR\Rapporten.xls" "" "$INSTDIR\Rapport.ico"
CreateShortCut "$DESKTOP\Start ${PRODUCT_NAME}.lnk" "$INSTDIR\Rapporten.xls" "" "$INSTDIR\Rapport.ico"
CreateShortCut "$QUICKLAUNCH\Start ${PRODUCT_NAME}.lnk" "$INSTDIR\Rapporten.xls" "" "$INSTDIR\Rapport.ico"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section "HANDLEIDING" SEC02
SetOutPath "$INSTDIR"
SetOverwrite off
File "C:\RapportBasis11\Nieuwe map\Handleiding1.doc"
File "C:\RapportBasis11\Nieuwe map\Book.ico"
; Shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
SetOverwrite off
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Handleiding1.lnk" "$INSTDIR\Handleiding1.doc" "" "$INSTDIR\Book.ico"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section -AdditionalIcons
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
SetOverwrite off
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Verkennen.lnk" "$INSTDIR\" "" "$INSTDIR\Explorer.ico"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Verwijderen.lnk" "$INSTDIR\Verwijderen.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section -Post
SetOverwrite off
WriteUninstaller "$INSTDIR\Verwijderen.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Verwijderen.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Installeerd het ${PRODUCT_NAME} programma met alle koppelingen: bureaublad, werkbalk snelstarten, menu Start, Programma's. Deze installatieoptie kan niet uitgeschakeld worden."
!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Installeerd een beknopte handleiding met de nodige koppeling in het menu Start, Programma's. Deze installatieoptie kan niet uitgeschakeld worden."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) is met succes verwijderd van uw computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Ben je zeker dat je alles wilt verwijderen van $(^Name)?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\Verwijderen.exe"
Delete "$INSTDIR\Handleiding1.doc"
Delete "$INSTDIR\Rapporten.xls"
Delete "$INSTDIR\Rapport.ico"
Delete "$INSTDIR\Book.ico"
Delete "$INSTDIR\Explorer.ico"
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Verwijderen.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Handleiding1.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Start ${PRODUCT_NAME}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Verkennen.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
Delete "$DESKTOP\Start ${PRODUCT_NAME}.lnk"
Delete "$QUICKLAUNCH\Start ${PRODUCT_NAME}.lnk"
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
RMDir "$INSTDIR"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd