SF.net SVN: geany:[3475] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Jan 17 13:10:13 UTC 2009


Revision: 3475
          http://geany.svn.sourceforge.net/geany/?rev=3475&view=rev
Author:   eht16
Date:     2009-01-17 13:10:13 +0000 (Sat, 17 Jan 2009)

Log Message:
-----------
Major improvements for the Windows installer:
Register ".geany" as Geany Project File extension.
Show a checkbox to open the Release Notes at the end of the installation.
When the installer is executed without admin privileges, install Geany only for the user. Otherwise, install Geany for All Users.
Fix problems with automatic uninstallation at startup of the installation when the installation directory were different.
Install GTK translation files only if installation of translation files were requested (saves about 22 MB otherwise).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/geany.nsi

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-01-16 22:59:35 UTC (rev 3474)
+++ trunk/ChangeLog	2009-01-17 13:10:13 UTC (rev 3475)
@@ -1,3 +1,19 @@
+2009-01-17  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * geany.nsi:
+   Major improvements for the Windows installer:
+   Register ".geany" as Geany Project File extension.
+   Show a checkbox to open the Release Notes at the end of the
+   installation.
+   When the installer is executed without admin privileges,
+   install Geany only for the user. Otherwise, install Geany
+   for All Users.
+   Fix problems with automatic uninstallation at startup of the
+   installation when the installation directory were different.
+   Install GTK translation files only if installation of translation
+   files were requested (saves about 22 MB otherwise).
+
+
 2009-01-16  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/project.c, src/keyfile.c:

Modified: trunk/geany.nsi
===================================================================
--- trunk/geany.nsi	2009-01-16 22:59:35 UTC (rev 3474)
+++ trunk/geany.nsi	2009-01-17 13:10:13 UTC (rev 3475)
@@ -1,96 +1,81 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; Installer script for Geany (Windows Installer)      ;
-; Script generated by the HM NIS Edit Script Wizard.  :
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; geany.nsi - this file is part of Geany, a fast and lightweight IDE
+;
+; Copyright 2007-2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+; Copyright 2007-2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+;
+; 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+;
+; $Id$
+;
+; Installer script for Geany (Windows Installer)
+; (Script originally generated by the HM NIS Edit Script Wizard)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
+; Do a Cyclic Redundancy Check to make sure the installer was not corrupted by the download
+CRCCheck force
+RequestExecutionLevel user ; set execution level for Windows Vista
+
 ;;;;;;;;;;;;;;;;;;;
 ; helper defines  ;
 ;;;;;;;;;;;;;;;;;;;
 !define PRODUCT_NAME "Geany"
 !define PRODUCT_VERSION "0.16"
 !define PRODUCT_VERSION_ID "0.16.0.0"
-!define PRODUCT_PUBLISHER "Enrico Troeger"
+!define PRODUCT_PUBLISHER "The Geany developer team"
 !define PRODUCT_WEB_SITE "http://www.geany.org/"
-!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Geany.exe"
+!define PRODUCT_DIR_REGKEY "Software\Geany"
 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
-!define PRODUCT_UNINST_ROOT_KEY "HKLM"
-!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
-
+!define PRODUCT_EXE "$INSTDIR\bin\Geany.exe"
+!define PRODUCT_REGNAME "Geany.ProjectFile"
+!define PRODUCT_EXT ".geany"
 !define RESOURCEDIR "geany-${PRODUCT_VERSION}"
 
-SetCompressor /SOLID lzma
+;;;;;;;;;;;;;;;;;;;;;
+; Version resource  ;
+;;;;;;;;;;;;;;;;;;;;;
+VIProductVersion "${PRODUCT_VERSION_ID}"
+VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
+VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
+VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
+VIAddVersionKey "LegalCopyright" "Copyright 2005-2009 by the Geany developer team"
+VIAddVersionKey "FileDescription" "${PRODUCT_NAME} Installer"
 
-XPStyle on
-; set execution level for Windows Vista
-RequestExecutionLevel user
-
+BrandingText "$(^NAME) installer (NSIS 2.42)"
+InstallDir "$PROGRAMFILES\Geany"
 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
-
-InstallDir "$PROGRAMFILES\Geany"
-InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
+SetCompressor /SOLID lzma
 ShowInstDetails hide
 ShowUnInstDetails hide
-
+XPStyle on
 !ifdef INCLUDE_GTK
 OutFile "geany-${PRODUCT_VERSION}_setup.exe"
 !else
 OutFile "geany-${PRODUCT_VERSION}_nogtk_setup.exe"
 !endif
 
-;;;;;;;;;;;;;;;;;;;;;
-; Version resource  ;
-;;;;;;;;;;;;;;;;;;;;;
-VIProductVersion "${PRODUCT_VERSION_ID}"
-VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
-VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
-VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
-VIAddVersionKey "LegalCopyright" "Copyright 2005-2009 by the Geany developers"
-VIAddVersionKey "FileDescription" "${PRODUCT_NAME} Installer"
+Var Answer
+Var UserName
+Var StartmenuFolder
+Var UNINSTDIR
 
-;Request application privileges for Windows Vista
-RequestExecutionLevel user
-
 ;;;;;;;;;;;;;;;;
-; Init code    ;
-;;;;;;;;;;;;;;;;
-Function .onInit
-  SetShellVarContext all
-
-  ; prevent running multiple instances of the installer
-  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "geany_installer") i .r1 ?e'
-  Pop $R0
-  StrCmp $R0 0 +3
-    MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
-    Abort
-  ; warn about a new install over an existing installation
-  ReadRegStr $R0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
-  StrCmp $R0 "" done
-
-  MessageBox MB_YESNO|MB_ICONEXCLAMATION \
-    "Geany has already been installed. $\nDo you want to remove the previous version before installing $(^Name) ?" \
-	/SD IDYES IDYES remove IDNO done
-
-  remove:
-  ;Run the uninstaller
-  ClearErrors
-  IfSilent dosilent nonsilent
-  dosilent:
-	;TODO read $INSTDIR from registry, the instdir of the old installation might be different
-	; from the new one (command line arg /D=...)
-	ExecWait '$R0 /S _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
-    Goto done
-  nonsilent:
-	ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
-
-  done:
-FunctionEnd
-
-
-;;;;;;;;;;;;;;;;
 ; MUI Settings ;
 ;;;;;;;;;;;;;;;;
-!include "MUI.nsh"
+!include "MUI2.nsh"
 
 !define MUI_ABORTWARNING
 !define MUI_ICON "pixmaps\geany.ico"
@@ -107,25 +92,23 @@
 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE OnDirLeave
 !insertmacro MUI_PAGE_DIRECTORY
 ; Start menu page
-var ICONS_GROUP
 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Geany"
-!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
+!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
-!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
-!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
+!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
+!insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} "$StartmenuFolder"
 ; Instfiles page
 !insertmacro MUI_PAGE_INSTFILES
 ; Finish page
+!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\News.txt"
+!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show Release Notes"
+!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
 !define MUI_FINISHPAGE_RUN "$INSTDIR\bin\Geany.exe"
+!define MUI_FINISHPAGE_RUN_NOTCHECKED
 !insertmacro MUI_PAGE_FINISH
-; Uninstaller pages
-!insertmacro MUI_UNPAGE_INSTFILES
-; Language files
-!insertmacro MUI_LANGUAGE "English"
-; Reserve files
-!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
-; MUI end ------
 
+!insertmacro MUI_UNPAGE_INSTFILES ; Uninstaller page
+!insertmacro MUI_LANGUAGE "English" ; Language file
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Sections and InstTypes  ;
@@ -155,10 +138,20 @@
   SetOutPath "$INSTDIR"
 
   CreateShortCut "$INSTDIR\Geany.lnk" "$INSTDIR\bin\Geany.exe"
-  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
-  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
-  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Geany.lnk" "$INSTDIR\bin\Geany.exe"
+  !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
+  CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
+  CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Geany.lnk" "$INSTDIR\bin\Geany.exe"
   !insertmacro MUI_STARTMENU_WRITE_END
+
+  ; register the extension .geany
+  ; write information about file type
+  WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Project File"
+  WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE},0"
+  WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_EXE}" "%1"'
+  ; write information about file extensions
+  WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
+  ; refresh shell
+  System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (0x08000000, 0, 0, 0)'
 SectionEnd
 
 Section "Plugins" SEC02
@@ -172,6 +165,10 @@
   SectionIn 1
   SetOutPath "$INSTDIR\share\locale"
   File /r "${RESOURCEDIR}\share\locale\*"
+!ifdef INCLUDE_GTK
+  SetOutPath "$INSTDIR\share"
+  File /r "gtk\share\*"
+!endif
 SectionEnd
 
 Section "Documentation" SEC04
@@ -180,8 +177,8 @@
   SetOutPath "$INSTDIR"
   File /r "${RESOURCEDIR}\doc"
   WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" "$INSTDIR\doc\Manual.html"
-  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
-  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Documentation.lnk" "$INSTDIR\Documentation.url"
+  !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
+  CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Documentation.lnk" "$INSTDIR\Documentation.url"
   !insertmacro MUI_STARTMENU_WRITE_END
 SectionEnd
 
@@ -199,7 +196,7 @@
 
 ; Include GTK runtime library but only if desired from command line
 !ifdef INCLUDE_GTK
-Section "GTK 2.12 Runtime Environment" SEC06
+Section "GTK 2.14 Runtime Environment" SEC06
   SectionIn 1
   SetOverwrite ifnewer
   SetOutPath "$INSTDIR\bin"
@@ -208,12 +205,6 @@
   File /r "gtk\etc\*"
   SetOutPath "$INSTDIR\lib"
   File /r "gtk\lib\*"
-  SetOutPath "$INSTDIR\share"
-  File /r "gtk\share\*"
-/* code to embed GTK+ installer executable
-  File ${GTK_INSTALLER}
-  ExecWait ${GTK_INSTALLER}
-*/
 SectionEnd
 !endif
 
@@ -231,26 +222,77 @@
 
 Section -AdditionalIcons
   SetOutPath $INSTDIR
-  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
+  !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
   WriteIniStr "$INSTDIR\Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
-  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" "$INSTDIR\Website.url"
-  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
+  CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Website.lnk" "$INSTDIR\Website.url"
+  CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe"
   !insertmacro MUI_STARTMENU_WRITE_END
 SectionEnd
 
 Section -Post
   WriteUninstaller "$INSTDIR\uninst.exe"
-  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\Geany.exe"
-  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\bin\Geany.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}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
-  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
+  WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" Path "$INSTDIR"
+  WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
+  ${if} $Answer == "yes" ; if user is admin
+    WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
+    WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
+    WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\Geany.exe"
+    WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
+    WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
+    WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
+    WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
+    WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
+    WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
+  ${endif}
 SectionEnd
 
+Section Uninstall
+  Delete "$INSTDIR\Website.url"
+  Delete "$INSTDIR\Documentation.url"
+  Delete "$INSTDIR\uninst.exe"
+  Delete "$INSTDIR\News.txt"
+  Delete "$INSTDIR\ReadMe.txt"
+  Delete "$INSTDIR\Thanks.txt"
+  Delete "$INSTDIR\ToDo.txt"
+  Delete "$INSTDIR\Authors.txt"
+  Delete "$INSTDIR\ChangeLog.txt"
+  Delete "$INSTDIR\Copying.txt"
+  Delete "$INSTDIR\Geany.lnk"
 
+  ; delete start menu entry
+  ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
+  RMDir /r "$0"
+
+  Delete "$QUICKLAUNCH\Geany.lnk"
+  Delete "$DESKTOP\Geany.lnk"
+
+  RMDir /r "$INSTDIR\bin"
+  RMDir /r "$INSTDIR\doc"
+  RMDir /r "$INSTDIR\data"
+  RMDir /r "$INSTDIR\etc"
+  RMDir /r "$INSTDIR\lib"
+  RMDir /r "$INSTDIR\share"
+  RMDir "$INSTDIR"
+
+  ; remove .geany file extension
+  ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
+  ${if} $R0 == "${PRODUCT_REGNAME}"
+   DeleteRegKey SHCTX "${PRODUCT_EXT}"
+   DeleteRegKey HKCR "${PRODUCT_EXT}"
+   DeleteRegKey SHCTX "${PRODUCT_REGNAME}"
+   DeleteRegKey HKCR "${PRODUCT_REGNAME}"
+  ${endif}
+
+  DeleteRegKey HKCR "*\shell\OpenWithGeany"
+
+  DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
+  DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
+  DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
+  DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
+
+  SetAutoClose true
+SectionEnd
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Section descriptions  ;
 ;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -267,16 +309,99 @@
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} "Create shortcuts for Geany on the desktop and in the Quicklaunch Bar"
 !insertmacro MUI_FUNCTION_DESCRIPTION_END
 
-
 ;;;;;;;;;;;;;;;;;;;;;
 ; helper functions  ;
 ;;;;;;;;;;;;;;;;;;;;;
+
+; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
+!macro IsUserAdmin Result UName
+
+ ClearErrors
+ UserInfo::GetName
+ IfErrors Win9x
+ Pop $0
+ StrCpy ${UName} $0
+ UserInfo::GetAccountType
+ Pop $1
+ ${if} $1 == "Admin"
+  StrCpy ${Result} "yes"
+ ${else}
+  StrCpy ${Result} "no"
+ ${endif}
+ Goto done
+
+ Win9x:
+  StrCpy ${Result} "yes"
+ done:
+!macroend
+
+Function .onInit
+  StrCpy "$StartmenuFolder" "Geany"
+
+  ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
+  ; If the user does *not* have administrator privileges, abort
+  StrCpy $Answer ""
+  StrCpy $UserName ""
+  !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
+  ${if} $Answer == "yes"
+   SetShellVarContext all ; set that e.g. shortcuts will be created for all users
+  ${else}
+   SetShellVarContext current
+   ; TODO is this really what we want? $PROGRAMFILES is not much better because
+   ; probably the unprivileged user can't write it anyways
+   StrCpy $INSTDIR "$PROFILE\$(^Name)"
+  ${endif}
+
+  ; prevent running multiple instances of the installer
+  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "geany_installer") i .r1 ?e'
+  Pop $R0
+  StrCmp $R0 0 +3
+    MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
+    Abort
+  ; warn about a new install over an existing installation
+  ReadRegStr $R0 SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString"
+  StrCmp $R0 "" finish
+
+  MessageBox MB_YESNO|MB_ICONEXCLAMATION \
+    "Geany has already been installed. $\nDo you want to remove the previous version before installing $(^Name) ?" \
+	/SD IDYES IDYES remove IDNO finish
+
+  remove:
+  ; run the uninstaller
+  ClearErrors
+  ; we read the installation path of the old installation from the Registry
+  ReadRegStr $UNINSTDIR SHCTX "${PRODUCT_DIR_REGKEY}" "Path"
+  IfSilent dosilent nonsilent
+  dosilent:
+	ExecWait '$R0 /S _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
+    Goto finish
+  nonsilent:
+	ExecWait '$R0 _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
+
+  finish:
+FunctionEnd
+
 Function un.onUninstSuccess
   HideWindow
   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
 FunctionEnd
 
 Function un.onInit
+  ; If the user does *not* have administrator privileges, abort
+  StrCpy $Answer ""
+  !insertmacro IsUserAdmin $Answer $UserName
+  ${if} $Answer == "yes"
+   SetShellVarContext all
+  ${else}
+   ; check if the Geany has been installed with admin permisions
+   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
+   ${if} $0 != ""
+    MessageBox MB_OK|MB_ICONSTOP "You need administrator privileges to uninstall Geany!" /SD IDOK
+    Abort
+   ${endif}
+   SetShellVarContext current
+  ${endif}
+
   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" /SD IDYES IDYES +2
   Abort
 FunctionEnd
@@ -297,40 +422,3 @@
   FileClose $0
   Delete "$1"
 FunctionEnd
-
-Section Uninstall
-  !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
-  Delete "$INSTDIR\Website.url"
-  Delete "$INSTDIR\Documentation.url"
-  Delete "$INSTDIR\uninst.exe"
-  Delete "$INSTDIR\News.txt"
-  Delete "$INSTDIR\ReadMe.txt"
-  Delete "$INSTDIR\Thanks.txt"
-  Delete "$INSTDIR\ToDo.txt"
-  Delete "$INSTDIR\Authors.txt"
-  Delete "$INSTDIR\ChangeLog.txt"
-  Delete "$INSTDIR\Copying.txt"
-  Delete "$INSTDIR\Geany.lnk"
-
-  Delete "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk"
-  Delete "$SMPROGRAMS\$ICONS_GROUP\Website.lnk"
-  Delete "$QUICKLAUNCH\Geany.lnk"
-  Delete "$DESKTOP\Geany.lnk"
-  Delete "$SMPROGRAMS\$ICONS_GROUP\Geany.lnk"
-  Delete "$SMPROGRAMS\$ICONS_GROUP\Documentation.lnk"
-
-  RMDir "$SMPROGRAMS\$ICONS_GROUP"
-  RMDir /r "$INSTDIR\bin"
-  RMDir /r "$INSTDIR\doc"
-  RMDir /r "$INSTDIR\data"
-  RMDir /r "$INSTDIR\etc"
-  RMDir /r "$INSTDIR\lib"
-  RMDir /r "$INSTDIR\share"
-  RMDir "$INSTDIR"
-
-  DeleteRegKey HKCR "*\shell\OpenWithGeany"
-
-  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
-  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
-  SetAutoClose true
-SectionEnd


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list