; Original script generated by the HM NIS Edit Script Wizard. ; now copied from agent installer and modified ; $Id: cartographer-gui.nsi 151 2011-03-31 14:33:54Z rdk $ ; mods by rdk ; ; Copyright 2011, Krupczak.org, LLC ; ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License as ; published by the Free Software Foundation; either version 2 of the ; License, or (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, but ; WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ; General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ; USA ; ----------------------------------------------------------------------- ; Variables and defines ; am I already installed? Is Java installed? Var alreadyInstalled Var javaAlreadyInstalled ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "Cartographer GUI" !define PRODUCT_VERSION "0.33" !define PRODUCT_PUBLISHER "Krupczak.org, LLC" !define PRODUCT_WEB_SITE "http://www.krupczak.org/cartographer" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Cartographer.jar" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" ; MUI 1.67 compatible ------ ; Use MUI2 instead of MUI 1.x !include "MUI2.nsh" !include "LogicLib.nsh" !include "servicelib.nsh" !include "x64.nsh" !include "WinVer.nsh" ; request application privileges for Vista+ RequestExecutionLevel admin BrandingText "© 2011 Krupczak.org, LLC. Installer made with NSIS" ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "cartographer-installer.ico" !define MUI_UNICON "cartographer-installer.ico" VIProductVersion "0.33.0.0" ViAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Cartographer GUI" ViAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Installer produced with NSIS and HM NIS Editor" ViAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Krupczak.org, LLC" ViAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright 2011, Krupczak.org, LLC" ViAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "0.33.0.0" ViAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Cartographer GUI Windows Installer" ; ----------------------------------------------------------------------- ; install pages ; Welcome page !insertmacro MUI_PAGE_WELCOME ; License page !insertmacro MUI_PAGE_LICENSE "license.txt" ; Directory page !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; write registry and use a page for it Page custom pageWriteRegistryStart ; Finish page !insertmacro MUI_PAGE_FINISH ; ----------------------------------------------------------------------- ; Uninstaller pages !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ; Language files !insertmacro MUI_LANGUAGE "English" ; MUI end ------ ; ----------------------------------------------------------------------- ; functions and page-functions ; prevent multiple instances of installer and check for other ; parameters at start of the installer ; if x64, set Registry view to 64 ; check if already installed; if installed and we wish to continue ; go ahead and try to stop the service anyway ; dont sleep as the service stop will wait for service to finish Function .onInit ${If} ${RunningX64} SetRegView 64 ${EndIf} ${If} ${AtMostWin2000} MessageBox MB_OK|MB_ICONEXCLAMATION "This installer cannot be run on anything prior to Windows XP" Abort ${EndIf} call isJavaInstalled StrCmp $javaAlreadyInstalled "true" carryOn 0 MessageBox MB_YESNO "Java is not installed; do you wish to continue anyway?" IDYES carryOnYes IDNO 0 Abort carryOnYes: carryOn: call isCartographerGUIInstalled StrCmp $alreadyInstalled "false" continueInstall 0 MessageBox MB_YESNO "Cartographer GUI is already installed. Do you wish to continue?" IDYES yesContinue IDNO 0 Abort yesContinue: continueInstall: System::Call 'kernel32::CreateMutexA(i 0, i 0, t "cartographerInstallerMutex") i .r1 ?e' Pop $R0 StrCmp $R0 0 +3 MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." Abort FunctionEnd ; ------------- ; dummy page to write registry entries ; Function pageWriteRegistryStart call writeRegistryEntries !insertmacro MUI_HEADER_TEXT "Writing Registry Entries" "" nsDialogs::Create 1018 ${NSD_CreateLabel} 0 5u 100% 20u "Writing Registry Entries" nsDialogs::Show FunctionEnd ; ------------- ; on win2k08, these entries do not appear to get written despite the ; fact that we ask for admin permissions ; its not win2k08, but 64-bit or 32-bit that is at work here ; use SetRegView to specify 32 or 64-bit Function writeRegistryEntries WriteRegStr HKLM "Software\Krupczak.org" "Description" "The Krupczak Organization" WriteRegStr HKLM "Software\Krupczak.org" "URL" "http://www.krupczak.org" WriteRegStr HKLM "Software\Krupczak.org\Cartographer GUI" "URL" "${PRODUCT_WEB_SITE}" WriteRegStr HKLM "Software\Krupczak.org\Cartographer GUI" "InstallDir" "$INSTDIR" WriteRegStr HKLM "Software\Krupczak.org\Cartographer GUI" "HowInstalled" "GUI" WriteRegStr HKLM "Software\Krupczak.org\Cartographer GUI" "Version" "${PRODUCT_VERSION}" FunctionEnd ; ------------- Function removeRegistryEntries DeleteRegKey HKLM "Software\Krupczak.org\Cartographer GUI" FunctionEnd Function un.removeRegistryEntries DeleteRegKey HKLM "Software\Krupczak.org\Cartographer GUI" FunctionEnd ; ------------- Function closeProgram Exch $1 Push $0 loop: FindWindow $0 $1 IntCmp $0 0 done # SendMessage $0 ${WM_DESTROY} 0 0 SendMessage $0 ${WM_CLOSE} 0 0 Sleep 100 Goto loop done: Pop $0 Pop $1 FunctionEnd Function un.closeProgram Exch $1 Push $0 loop: FindWindow $0 $1 IntCmp $0 0 done # SendMessage $0 ${WM_DESTROY} 0 0 SendMessage $0 ${WM_CLOSE} 0 0 Sleep 100 Goto loop done: Pop $0 Pop $1 FunctionEnd ; ------------- ; is Cartographer GUI already installed? ; check if file Cartographer.jar exists Function isCartographerGUIInstalled !undef UN !define UN "" StrCpy $alreadyInstalled "false" ifFileExists $INSTDIR\Cartographer.jar 0 notExists StrCpy $alreadyInstalled "true" notExists: FunctionEnd ; ------------- ; is Java JRE installed? ; check registry entries Function isJavaInstalled !undef UN !define UN "" Push $R0 StrCpy $javaAlreadyInstalled "false" ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion" StrCmp $R0 "" JRENotFound StrCpy $javaAlreadyInstalled "true" JRENotFound: FunctionEnd ; ----------------------------------------------------------------------- ; sections Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "cartographer-gui.exe" InstallDir "$PROGRAMFILES\cartographer-gui" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show ShowUnInstDetails show Section "MainSection" SEC01 SetOutPath "$INSTDIR" SetOverwrite try File "lib\Cartographer.jar" File "lib\Xmp.jar" File "lib\jgraph.jar" File "lib\jgraphlayout.jar" File "lib\license.txt" SectionEnd ; ------------------------------------------------ Section -AdditionalIcons WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" CreateShortCut "$SMPROGRAMS\Cartographer-GUI\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" CreateShortCut "$SMPROGRAMS\Cartographer-GUI\Uninstall.lnk" "$INSTDIR\uninst.exe" SectionEnd ; ------------------------------------------------ Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Cartographer.jar" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\xmpd-win32.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 ; ------------------------------------------------ ; this function invoked after successful install Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd ; this function invoked before install starts ; prevent multiple instance of uninstaller ; if x64, set Registry view to 64 Function un.onInit ${If} ${RunningX64} SetRegView 64 ${EndIf} System::Call 'kernel32::CreateMutexA(i 0, i 0, t "cartographerInstallerMutex") i .r1 ?e' Pop $R0 StrCmp $R0 0 +3 MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." Abort MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 Abort FunctionEnd ; ------------------------------------------------ Section Uninstall DetailPrint "Removing registry entries" call un.removeRegistryEntries Delete "$INSTDIR\${PRODUCT_NAME}.url" Delete "$INSTDIR\Cartographer.jar" Delete "$INSTDIR\Xmp.jar" Delete "$INSTDIR\jgraph.jar" Delete "$INSTDIR\jgraphlayout.jar" Delete "$INSTDIR\license.txt" ; finally, remove the install dir RmDir "$INSTDIR" Delete "$SMPROGRAMS\Cartographer-GUI\Uninstall.lnk" Delete "$SMPROGRAMS\Cartographer-GUI\Website.lnk" RMDir "$SMPROGRAMS\Cartographer-GUI" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" SetAutoClose true SectionEnd ; -----------------------------------------------------------------------