;-----CONSTANTS !define VERSION_STRING "1.4" !define VERSION_MAJOR 1 !define VERSION_MINOR 4 !define PRODUCT_NAME "uritoxml" !define PRODUCT_TITLE "uri/url/text to xml converter (and back)" !define PRODUCT_ABOUTURL "http://uritoxml.sf.net" !define PRODUCT_URL "http://sf.net/projects/uritoxml" /* Copyright 2009 Jim Michaels, Joost Verburg ;NSIS Modern User Interface ;Start Menu Folder Selection Example Script ;Written by Joost Verburg ;mostly modified by Jim Michaels June Sept 25, 2009 I recommend Notepad++ for a programmer's editor if you are editing NSIS files. it is available from http://notepad-plus.sourceforge.net/uk/site.htm NSIS is available at http://nsis.sourceforge.net/Download plugins you will need for compiling this script are available at http://nsis.sourceforge.net/Processes_plug-in (used for killing off processes before uninstall so they don't lock files during delete) optional article: http://forums.winamp.com/showthread.php?s=cb7189b462418eab271bbb3a916150f4&postid=2521977#post2521977 (find and uninstall old version) optional: http://nsis.sourceforge.net/GetVersion_%28Windows%29_plug-in optional: http://nsis.sourceforge.net/ExecWait_and_waiting_for_child_processes_with_Job_Objects optional article: http://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs optional: http://nsis.sourceforge.net/Get_.NET_Version optional: http://nsis.sourceforge.net/Include/x64.nsh optionally create an autorun.inf for making a auto-insert cd ISO on windows. it should have the content: [autorun] OPEN=reduce-20091021-setup.exe you will have to delete the old setup.exe file before recompiling a new setup.exe file, lest it include that in the new setup program. */ /* Copyright 2009 Jim Michaels, Joost Verburg This file is part of pwdgen. pwdgen 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 3 of the License, or (at your option) any later version. pwdgen 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 pwdgen. If not, see . */ ;NSIS Modern User Interface ;Start Menu Folder Selection Example Script ;Written by Joost Verburg ;mostly modified by Jim Michaels June 28-29, 2009 ;-------------------------------- ;Include Modern UI RequestExecutionLevel admin ;gotta do this to have uninstallation it seems, required for HKLM access !include "MUI2.nsh" !include "x64.nsh" !include "shortcut.nsh" ;-------------------------------- ;General ;Name and file Name "${PRODUCT_TITLE}" OutFile "${PRODUCT_NAME}-${VERSION_STRING}-setup.exe" ;Default installation folder ; InstallDir "$LOCALAPPDATA\${PRODUCT_NAME}" ;Get installation folder from registry if available InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" "" ;Request application privileges for Windows Vista RequestExecutionLevel admin ;-------------------------------- ;Variables Var StartMenuFolder ;-------------------------------- ;Interface Settings !define MUI_ABORTWARNING Function .onInit #prevent multiple instances of the installer running System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${PRODUCT_NAME}-setup") i .r1 ?e' Pop $R0 StrCmp $R0 0 +3 MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." Abort ; SetOutPath "." ; File /oname=$PLUGINSDIR\welcome.bmp "${NSISDIR}\Contrib\Graphics\Wizard\orange-nsis.bmp" ; File "setup.ini" GetDlgItem $0 $HWNDPARENT 1 CreateFont $1 "$(^Font)" "14" "700" ;culprit. worked in older versions. what do I do now? got this from the forums. ; CreateFont $HEADLINE_FONT "$(^Font)" "14" "700" InitPluginsDir ; SetOutPath "$PLUGINSDIR" ${If} ${RunningX64} SetRegView 64 StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}" SetOutPath "$PROGRAMFILES64\${PRODUCT_NAME}" ${Else} SetRegView 32 StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_NAME}" SetOutPath "$PROGRAMFILES\${PRODUCT_NAME}" ${EndIf} SetShellVarContext all FunctionEnd ;-------------------------------- ;Pages !insertmacro MUI_PAGE_WELCOME ; !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" !insertmacro MUI_PAGE_LICENSE "gpl3license.txt" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY ;Start Menu Folder Page Configuration !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Jim Michaels\${PRODUCT_NAME}" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ;Installer Sections Section "-Dummy Section" SecDummy File /r /x "${PRODUCT_NAME}-${VERSION_STRING}-setup.exe" *.* ;goes to ; SetOutPath "$INSTDIR" ;ADD YOUR OWN FILES HERE... ;Store installation folder WriteRegStr HKCU "Software\Jim Michaels\${PRODUCT_NAME}" "" $INSTDIR ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts CreateDirectory "$SMPROGRAMS\$StartMenuFolder" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" ;set up add/remove programs control panel entry ${If} ${RunningX64} WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "InstallLocation" "$PROGRAMFILES64\${PRODUCT_NAME}" ${Else} WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "InstallLocation" "$PROGRAMFILES\${PRODUCT_NAME}" ${EndIf} WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_TITLE} ${VERSION_STRING}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${VERSION_STRING}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "Jim Michaels" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "URLInfoAbout" "${PRODUCT_ABOUTURL}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "URLUpdateInfo" "${PRODUCT_URL}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "VersionMajor" ${VERSION_MAJOR} WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "VersionMinor" ${VERSION_MINOR} !insertmacro MUI_STARTMENU_WRITE_END SectionEnd Section "${PRODUCT_NAME}, GUI(Windows) ${VERSION_STRING}" Sec_gui CreateDirectory '$SMPROGRAMS\$StartMenuFolder' CreateShortCut '$SMPROGRAMS\$StartMenuFolder\gpl3license.lnk' '$INSTDIR\gpl3license.txt' CreateShortCut '$SMPROGRAMS\$StartMenuFolder\readme.lnk' '$INSTDIR\readme.txt' !insertmacro shortcut 'url' '$SMPROGRAMS\$StartMenuFolder\site' '${PRODUCT_URL}' '' ${If} ${RunningX64} !insertmacro shortcut 'lnk' '$SMPROGRAMS\$StartMenuFolder\${PRODUCT_TITLE}' '$INSTDIR\64\uritoxmlgui.exe' '$INSTDIR\64\' ${Else} !insertmacro shortcut 'lnk' '$SMPROGRAMS\$StartMenuFolder\${PRODUCT_TITLE}' '$INSTDIR\32\uritoxmlgui.exe' '$INSTDIR\32\' ${EndIf} ;MessageBox MB_OK|MB_ICONEXCLAMATION "add '$INSTDIR\cmd-line\win' from your PATH. This installer cannot do it safely." SectionEnd Section "${PRODUCT_NAME}, cmd-line ${VERSION_STRING}" Sec_cmd CreateDirectory '$SMPROGRAMS\$StartMenuFolder' !insertmacro shortcut 'url' '$SMPROGRAMS\$StartMenuFolder\site' '${PRODUCT_URL}' '' CreateShortCut '$SMPROGRAMS\$StartMenuFolder\gpl3license.lnk' '$INSTDIR\gpl3license.txt' CreateShortCut '$SMPROGRAMS\$StartMenuFolder\readme.lnk' '$INSTDIR\readme.txt' SectionEnd ;-------------------------------- ;Descriptions ;Language strings ; LangString DESC_Sec_dos ${LANG_ENGLISH} "pwdgen, Command-line version(DOS)" LangString DESC_Sec_cmd ${LANG_ENGLISH} "${PRODUCT_TITLE}, Command-line version(Windows and DOS). DOS/9x/me/nt/2000/2003/xp/vista/7." LangString DESC_Sec_gui ${LANG_ENGLISH} "${PRODUCT_TITLE}, GUI version(Windows). 32 and 64-bit. 2000/2003/xp/vista/7." ;Assign language strings to sections. ;makes checkboxes in the installer page in this order. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${Sec_gui} $(DESC_Sec_gui) !insertmacro MUI_DESCRIPTION_TEXT ${Sec_cmd} $(DESC_Sec_cmd) ; !insertmacro MUI_DESCRIPTION_TEXT ${Sec_dos} $(DESC_Sec_dos) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section Function un.onInit ;set context of $SMPROGRAMS and $APPDATA to All Users rather than Current User. SetShellVarContext all FunctionEnd Section "Uninstall" ;close any open windows of pwdgen a0: Processes::FindProcess "uritoxml" ;without ".exe" Pop $R0 StrCmp $R0 "1" +1 a1 ;if found kill process else go to next ; Searches the currently running processes for the given ; process name. ; ; return: 1 - the process was found ; 0 - the process was not found Processes::KillProcess "uritoxml" ; without ".exe" ; Searches the currently running processes for the given ; process name. If the process is found then the it gets ; killed. ; ; return: 1 - the process was found and killed ; 0 - the process was not found or the process ; cannot be killed (insuficient rights) Pop $R0 StrCmp $R0 "1" a0 a1 ;if process killed, loop back and kill more of same, else go to next a1: Processes::FindProcess "uritoxml64" ;without ".exe" Pop $R0 StrCmp $R0 "1" +1 a2 ;if found kill process else go to next ; Searches the currently running processes for the given ; process name. ; ; return: 1 - the process was found ; 0 - the process was not found Processes::KillProcess "uritoxml64" ; without ".exe" ; Searches the currently running processes for the given ; process name. If the process is found then the it gets ; killed. ; ; return: 1 - the process was found and killed ; 0 - the process was not found or the process ; cannot be killed (insuficient rights) Pop $R0 StrCmp $R0 "1" a1 a2 ;if process killed, loop back and kill more of same, else go to next a2: Processes::FindProcess "uritoxmlgui64" ;without ".exe" Pop $R0 StrCmp $R0 "1" +1 a3 ;if found kill process else go to next ; Searches the currently running processes for the given ; process name. ; ; return: 1 - the process was found ; 0 - the process was not found Processes::KillProcess "uritoxmlgui64" ; without ".exe" ; Searches the currently running processes for the given ; process name. If the process is found then the it gets ; killed. ; ; return: 1 - the process was found and killed ; 0 - the process was not found or the process ; cannot be killed (insuficient rights) Pop $R0 StrCmp $R0 "1" a2 a3 ;if process killed, loop back and kill more of same, else go to next a3: Processes::FindProcess "uritoxmlgui" ;without ".exe" Pop $R0 StrCmp $R0 "1" +1 a4 ;if found kill process else go to next ; Searches the currently running processes for the given ; process name. ; ; return: 1 - the process was found ; 0 - the process was not found Processes::KillProcess "uritoxmlui" ; without ".exe" ; Searches the currently running processes for the given ; process name. If the process is found then the it gets ; killed. ; ; return: 1 - the process was found and killed ; 0 - the process was not found or the process ; cannot be killed (insuficient rights) Pop $R0 StrCmp $R0 "1" a3 a4 ;if process killed, loop back and kill more of same, else go to next a4: Processes::FindProcess "readme" ;without ".exe" Pop $R0 StrCmp $R0 "1" +1 a5 ;if found kill process else go to next ; Searches the currently running processes for the given ; process name. ; ; return: 1 - the process was found ; 0 - the process was not found Processes::KillProcess "readme" ; without ".exe" ; Searches the currently running processes for the given ; process name. If the process is found then the it gets ; killed. ; ; return: 1 - the process was found and killed ; 0 - the process was not found or the process ; cannot be killed (insuficient rights) Pop $R0 StrCmp $R0 "1" a4 a5 ;if process killed, loop back and kill more of same, else go to next a5: Processes::FindProcess "gpl3license" ;without ".exe" Pop $R0 StrCmp $R0 "1" +1 a6 ;if found kill process else go to next ; Searches the currently running processes for the given ; process name. ; ; return: 1 - the process was found ; 0 - the process was not found Processes::KillProcess "gpl3license" ; without ".exe" ; Searches the currently running processes for the given ; process name. If the process is found then the it gets ; killed. ; ; return: 1 - the process was found and killed ; 0 - the process was not found or the process ; cannot be killed (insuficient rights) Pop $R0 StrCmp $R0 "1" a5 a6 ;if process killed, loop back and kill more of same, else go to next a6: Delete "$INSTDIR\Uninstall.exe" !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder ${If} $StartMenuFolder == "" Goto dontdoit ${EndIf} Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" ;remove files Delete '$INSTDIR\*.*' Delete '$INSTDIR\dos\*.*' Delete '$INSTDIR\32\*.*' Delete '$INSTDIR\64\*.*' ;delete shortcuts Delete '$SMPROGRAMS\$StartMenuFolder\gpl3license.lnk' Delete '$SMPROGRAMS\$StartMenuFolder\readme.lnk' Delete '$SMPROGRAMS\$StartMenuFolder\site.url' Delete '$SMPROGRAMS\$StartMenuFolder\${PRODUCT_TITLE}.lnk' ;after removing files, remove subdirectories the files were in. RMDir '$INSTDIR\dos' RMDir '$INSTDIR\js' RMDir '$INSTDIR\perl' RMDir '$INSTDIR\autoit3' ;MessageBox MB_OK|MB_ICONEXCLAMATION "remove '$INSTDIR\cmd-line\win' and '$INSTDIR\cmd-line\dos' from your PATH. This installer cannot do it safely." ;remove add/remove programs control panel entry ;remove directories, c:\program files subfolder and Start Menu subfolder RMDir /r /REBOOTOK '$INSTDIR' RMDir /r /REBOOTOK "$SMPROGRAMS\$StartMenuFolder" DeleteRegKey /ifempty HKCU "Software\${PRODUCT_NAME}" DeleteRegKey HKCU "Software\Jim Michaels\${PRODUCT_NAME}" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" dontdoit: SectionEnd