# Auto-generated by EclipseNSIS Script Wizard
# 27-ago-2006 19.54.24

Name Scuolabus
# Defines
!define REGKEY "SOFTWARE\$(^Name)"
!define VERSION 1.004
!define COMPANY "PBsoft di Gabriele Bertolucci"
!define URL "www.pbsoft.it"

# MUI defines
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN $INSTDIR\post_install.cmd
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_UNFINISHPAGE_NOAUTOCLOSE

# Included files
!include Sections.nsh
!include MUI.nsh

# Reserved Files

# Variables
Var StartMenuGroup

# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

# Installer languages
!insertmacro MUI_LANGUAGE Italian

# Installer attributes
OutFile Scuolabus_setup.exe
InstallDir $PROGRAMFILES\Scuolabus
CRCCheck on
XPStyle on
ShowInstDetails show
VIProductVersion 1.4.0.0
VIAddVersionKey /LANG=${LANG_ITALIAN} ProductName Scuolabus
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey /LANG=${LANG_ITALIAN} CompanyName "${COMPANY}"
VIAddVersionKey /LANG=${LANG_ITALIAN} CompanyWebsite "${URL}"
VIAddVersionKey /LANG=${LANG_ITALIAN} FileVersion ""
VIAddVersionKey /LANG=${LANG_ITALIAN} FileDescription ""
VIAddVersionKey /LANG=${LANG_ITALIAN} LegalCopyright ""
InstallDirRegKey HKLM "${REGKEY}" Path
ShowUninstDetails show

# Installer sections
Section "!Componenti principali" SEC0000
    SetOutPath $INSTDIR
    SetOverwrite on
    File ..\..\..\..\..\Access2003\Scuolabus\Scuolabus.mde
    File ..\..\..\..\..\Access2003\PBlib2003\PBlib2003.mde
    File ..\..\..\..\..\Access2003\RTF2.ocx
    File ..\..\..\..\..\Access2003\Scuolabus\Versione.txt
    File ..\..\..\..\..\Access2003\Scuolabus\post_install.cmd
    SetOutPath $SMPROGRAMS\$StartMenuGroup
    CreateShortcut $SMPROGRAMS\$StartMenuGroup\Scuolabus.lnk $INSTDIR\Scuolabus.mde
    WriteRegStr HKLM "${REGKEY}\Components" "Componenti principali" 1
SectionEnd

Section Manutenzione SEC0001
    SetOutPath $INSTDIR
    SetOverwrite on
    File ..\..\..\..\..\Access2003\Manutenzione\Manutenzione.mde
    SetOutPath $SMPROGRAMS\$StartMenuGroup
    CreateShortcut $SMPROGRAMS\$StartMenuGroup\Manutenzione.lnk $INSTDIR\Manutenzione.mde
    WriteRegStr HKLM "${REGKEY}\Components" Manutenzione 1
SectionEnd

Section /o "Dati iniziali" SEC0002
    SetOutPath $INSTDIR
    SetOverwrite on
    File ..\..\..\..\..\Access2003\Scuolabus\ScuolabusDati.mdb
    WriteRegStr HKLM "${REGKEY}\Components" "Dati iniziali" 1
SectionEnd

Section /o "Runtime Access 2003" SEC0003
    SetOutPath $INSTDIR
    SetOverwrite on
    File ..\..\..\..\..\Access2003\Scuolabus\Package\Scuolabus_2006-08-27\Files\ACCESSRT.MSI
    File ..\..\..\..\..\Access2003\Scuolabus\Package\Scuolabus_2006-08-27\Files\ACCESSRT.CAB
    WriteRegStr HKLM "${REGKEY}\Components" "Runtime Access 2003" 1
SectionEnd

Section -post SEC0004
    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
    WriteUninstaller $INSTDIR\Scuolabus_uninstall.exe
    !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
    SetOutPath $SMPROGRAMS\$StartMenuGroup
    CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk" $INSTDIR\Scuolabus_uninstall.exe
    !insertmacro MUI_STARTMENU_WRITE_END
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\Scuolabus_uninstall.exe
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\Scuolabus_uninstall.exe
    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
SectionEnd

# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
    Push $R0
    ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
    StrCmp $R0 1 0 next${UNSECTION_ID}
    !insertmacro SelectSection "${UNSECTION_ID}"
    GoTo done${UNSECTION_ID}
next${UNSECTION_ID}:
    !insertmacro UnselectSection "${UNSECTION_ID}"
done${UNSECTION_ID}:
    Pop $R0
!macroend

# Uninstaller sections
Section /o "un.Runtime Access 2003" UNSEC0003
    Delete /REBOOTOK $INSTDIR\ACCESSRT.CAB
    Delete /REBOOTOK $INSTDIR\ACCESSRT.MSI
    DeleteRegValue HKLM "${REGKEY}\Components" "Runtime Access 2003"
SectionEnd

Section /o "un.Dati iniziali" UNSEC0002
    Delete /REBOOTOK $INSTDIR\ScuolabusDati.mdb
    DeleteRegValue HKLM "${REGKEY}\Components" "Dati iniziali"
SectionEnd

Section /o un.Manutenzione UNSEC0001
    Delete /REBOOTOK $SMPROGRAMS\$StartMenuGroup\Manutenzione.lnk
    Delete /REBOOTOK $INSTDIR\Manutenzione.mde
    DeleteRegValue HKLM "${REGKEY}\Components" Manutenzione
SectionEnd

Section /o "un.Componenti principali" UNSEC0000
    Delete /REBOOTOK $SMPROGRAMS\$StartMenuGroup\Scuolabus.lnk
    Delete /REBOOTOK $INSTDIR\post_install.cmd
    Delete /REBOOTOK $INSTDIR\Versione.txt
    Delete /REBOOTOK $INSTDIR\RTF2.ocx
    Delete /REBOOTOK $INSTDIR\PBlib2003.mde
    Delete /REBOOTOK $INSTDIR\Scuolabus.mde
    DeleteRegValue HKLM "${REGKEY}\Components" "Componenti principali"
SectionEnd

Section un.post UNSEC0004
    DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
    Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"
    Delete /REBOOTOK $INSTDIR\Scuolabus_uninstall.exe
    DeleteRegValue HKLM "${REGKEY}" StartMenuGroup
    DeleteRegValue HKLM "${REGKEY}" Path
    DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
    DeleteRegKey /IfEmpty HKLM "${REGKEY}"
    RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
    RmDir /REBOOTOK $INSTDIR
SectionEnd

# Installer functions
Function .onInit
    InitPluginsDir
    StrCpy $StartMenuGroup Scuolabus
FunctionEnd

# Uninstaller functions
Function un.onInit
    ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
    ReadRegStr $StartMenuGroup HKLM "${REGKEY}" StartMenuGroup
    !insertmacro SELECT_UNSECTION "Componenti principali" ${UNSEC0000}
    !insertmacro SELECT_UNSECTION Manutenzione ${UNSEC0001}
    !insertmacro SELECT_UNSECTION "Dati iniziali" ${UNSEC0002}
    !insertmacro SELECT_UNSECTION "Runtime Access 2003" ${UNSEC0003}
FunctionEnd


# Installer Language Strings
# TODO Update the Language Strings with the appropriate translations.

LangString ^UninstallLink ${LANG_ITALIAN} "Uninstall $(^Name)"
