GFORCE100
17th November 2004 20:26 UTC
Originally posted by Afrow UK
Please attach your script.
-Stu
Here goes.....quite long so far.
;**************************************************************************************************
;**************************************************************************************************
;Setup program, VERSION 1.00
;**************************************************************************************************
;**************************************************************************************************
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
!include "Library.nsh"
;--------------------------------
;GENERAL
Var ALREADY_INSTALLED
Var STARTMENU_FOLDER
Var MUI_TEMP
var STARTMENU_LINK_APP_FILENAME
var STARTMENU_LINK_APP_NAME
var STARTMENU_LINK_APP_UNINSTALL
var STARTMENU_LINK_APP_HELP
;**************************************************************************************************
;Name and file
;**************************************************************************************************
Name "XXX 2005"
SetFont "MS Sans Serif" 8
OutFile "Setup.exe"
;**************************************************************************************************
;Default installation folder
;**************************************************************************************************
InstallDir "$EXEDIR\XXX YYY\"
;**************************************************************************************************
;Get installation folder from registry if available
;**************************************************************************************************
InstallDirRegKey HKLM "Software\XXX\YYY\Uninstall" ""
BrandingText /TRIMLEFT XXX 2005 Setup"
XPStyle on
;--------------------------------
;INTERFACE CONFIGURATION
;**************************************************************************************************
;General
;**************************************************************************************************
!define MUI_ICON "Images\setup.ico"
!define MUI_UNICON "Images\setup.ico"
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_ABORTWARNING
XPStyle on
;**************************************************************************************************
;Install interface
;**************************************************************************************************
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_HEADERIMAGE_BITMAP "Images\header.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "Images\welcome.bmp"
!define MUI_FINISHPAGE_TITLE XXX 2005 has been installed."
!define MUI_FINISHPAGE_TEXT_REBOOTNOW "Reboot now (Recommended)"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\XXX\YYY"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
;**************************************************************************************************
;Uninstall interface
;**************************************************************************************************
!define MUI_HEADERIMAGE_UNBITMAP "Images\header.bmp"
!define MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH
;**************************************************************************************************
;Start Menu link names
;**************************************************************************************************
;!define STARTMENU_LINK_APP_NAME "Start XXX"
;!define STARTMENU_LINK_APP_FILENAME "XXX"
;!define STARTMENU_LINK_APP_UNINSTALL "Uninstall"
;!define STARTMENU_LINK_APP_HELP "View Help"
;--------------------------------
;PAGES
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "Data\license.txt"
;!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;LANGUAGES
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;INSTALLER SECTIONS ###############################################################################
;/////////////////////////////////////////////////////////
Section "Standard installation" StandardInstall
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SetOutPath "$INSTDIR" ;Root folder of installation
;**************************************************************************************************
;PROGRAM FILES
;**************************************************************************************************
File WorkMate.exe
;**************************************************************************************************
;PROGRAM DOCUMENTATION FILES
;**************************************************************************************************
SetOutPath "$INSTDIR\Help" ;Root folder of installation + \Help
File /r "Help\*.*"
;**************************************************************************************************
;Store installation folder
;**************************************************************************************************
WriteRegStr HKLM "Software\XXX\YYY" "Install Folder" $INSTDIR
;**************************************************************************************************
;Create uninstaller
;**************************************************************************************************
WriteUninstaller "$INSTDIR\Uninstall.exe"
;**************************************************************************************************
;Write uninstall registry info for Windows Add/Remove Programs option in Control Panel
;**************************************************************************************************
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YYY\" "DisplayName" "YYY"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YYY\" "Publisher" "XXX"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YYY\" "URLInfoAbout" "http://www.xxx.net"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YYY\" "Publisher" "XXX"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YYY\" "DisplayVersion" "2004"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YYY\" "UninstallString" "$INSTDIR\Uninstall.exe"
;**************************************************************************************************
;Write Start Menu links
;**************************************************************************************************
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create Start Menu shortcuts
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\$STARTMENU_LINK_APP_NAME.lnk" "$INSTDIR\$STARTMENU_LINK_APP_FILENAME.exe"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\$STARTMENU_LINK_APP_UNINSTALL.lnk" "$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\$STARTMENU_LINK_APP_HELP.lnk" "$INSTDIR\Help\index.htm"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
;/////////////////////////////////////////////////////////
Section "-Install VB6 runtimes"
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;Check if this is a new installation
IfFileExists "$INSTDIR\MyApp.exe" 0 New_Installation
StrCpy $ALREADY_INSTALLED 1
New_Installation:
!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "VB6Runtime\msvbvm60.dll" "$SYSDIR\msvbvm60.dll" "$SYSDIR"
!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "VB6Runtime\oleaut32.dll" "$SYSDIR\oleaut32.dll" "$SYSDIR"
!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "VB6Runtime\olepro32.dll" "$SYSDIR\olepro32.dll" "$SYSDIR"
!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "VB6Runtime\comcat.dll" "$SYSDIR\comcat.dll" "$SYSDIR"
!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_PROTECTED "VB6Runtime\asycfilt.dll" "$SYSDIR\asycfilt.dll" "$SYSDIR"
!insertmacro InstallLib TLB $ALREADY_INSTALLED REBOOT_PROTECTED "VB6Runtime\stdole2.tlb" "$SYSDIR\stdole2.tlb" "$SYSDIR"
SetRebootFlag true
SectionEnd
;--------------------------------
;DESCRIPTIONS
;**************************************************************************************************
;Language strings
;**************************************************************************************************
LangString DESC_StandardInstall ${LANG_ENGLISH} "Standard installation."
;**************************************************************************************************
;Assign language strings to sections
;**************************************************************************************************
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${StandardInstall} $(DESC_StandardInstall)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;UNINSTALLER SECTIONS #############################################################################
;/////////////////////////////////////////////////////////
Section "Uninstall"
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;**************************************************************************************************
;Delete files created upon installation
;**************************************************************************************************
Delete "$INSTDIR\Help\*.*"
Delete "$INSTDIR\*.*"
;**************************************************************************************************
;Delete folders created upon installation
;**************************************************************************************************
RMDir /r "$INSTDIR"
;**************************************************************************************************
;Delete Start Menu links
;**************************************************************************************************
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
Delete "$SMPROGRAMS\$MUI_TEMP\$STARTMENU_LINK_APP_NAME.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\$STARTMENU_LINK_APP_UNINSTALL.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\$STARTMENU_LINK_APP_HELP.lnk"
;Delete empty start menu parent diretories
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
RMDir $MUI_TEMP
ClearErrors
;**************************************************************************************************
;Delete created registry keys
;**************************************************************************************************
DeleteRegKey HKLM "Software\XXX"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YYY"
SectionEnd
;/////////////////////////////////////////////////////////
Section "-un.Uninstall VB6 runtimes"
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
!insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\msvbvm60.dll"
!insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\oleaut32.dll"
!insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\olepro32.dll"
!insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\comcat32.dll"
!insertmacro UnInstallLib DLL SHARED NOREMOVE "$SYSDIR\asycfilt.dll"
!insertmacro UnInstallLib TLB SHARED NOREMOVE "$SYSDIR\stdole2.tlb"
SectionEnd
;--------------------------------
;INIT SECTION
Function .onInit
StrCpy $STARTMENU_LINK_APP_NAME "Start XXXX"
StrCpy $STARTMENU_LINK_APP_FILENAME "XXX"
StrCpy $STARTMENU_LINK_APP_UNINSTALL "Uninstall"
StrCpy $STARTMENU_LINK_APP_HELP "View Help"
SetOutPath $TEMP
File /oname=spltmp.bmp "Images\splash.bmp"
; optional
; File /oname=spltmp.wav "Data\splash.wav"
splash::show 1000 $TEMP\spltmp
Pop $0 ; $0 has '1' if the user closed the splash screen early,
; '0' if everything closed normal, and '-1' if some error occured.
Delete $TEMP\spltmp.bmp
; Delete $TEMP\spltmp.wav
FunctionEnd