home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / TaskSwitchXP / TaskSwitchXP_1.0.26.exe / Source / TaskSwitchXP.nsi < prev   
Text File  |  2004-10-07  |  21KB  |  573 lines

  1. ; NSIS Script
  2.  
  3. ; Help defines
  4. !define VER_MAJOR 1
  5. !define VER_MINOR 0
  6. !define VER_BUILD 26
  7. !define VER_REVISION 0
  8.  
  9. !define PRODUCT_NAME "TaskSwitchXP"
  10. !define PRODUCT_PUBLISHER "Alexander Avdonin"
  11. !define PRODUCT_WEB_SITE "http://taskswitchxp.sourceforge.net"
  12. !define PRODUCT_PUBLISHER_REGKEY "Software\Alexander Avdonin"
  13. !define PRODUCT_DIR_REGKEY "${PRODUCT_PUBLISHER_REGKEY}\${PRODUCT_NAME}"
  14. !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  15. !define APP_PATHS_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths"
  16. !define RUN_REGKEY "Software\Microsoft\Windows\CurrentVersion\Run"
  17.  
  18. !define ICONS_GROUP "${PRODUCT_NAME}"
  19. !define REG_ALL_USERS "NSIS_AllUsers"
  20. !define REG_START_SHORTCUTS "NSIS_StartMenuShortcuts"
  21. !define REG_DESKTOP_SHORTCUTS "NSIS_DesktopShortcuts"
  22.  
  23. !define PRODUCT_VERSION "${VER_MAJOR}.${VER_MINOR}"
  24. !define PRODUCT_VERSION2 "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}"
  25. !define PRODUCT_VERSION3 "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}.${VER_REVISION}"
  26. !define HWND_MESSAGE -3
  27.  
  28. ;-------------------------------------------------------------------------
  29. ;Header Files
  30.  
  31. !include "MUI.nsh"
  32. !include "WinMessages.nsh"
  33. SetCompressor lzma
  34.  
  35. ;-------------------------------------------------------------------------
  36. ; MUI Settings
  37. !define MUI_ABORTWARNING
  38. !define MUI_COMPONENTSPAGE_SMALLDESC
  39.  
  40. !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\arrow2-install.ico"
  41. !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\arrow2-uninstall.ico"
  42.  
  43. !insertmacro MUI_PAGE_WELCOME
  44. !insertmacro MUI_PAGE_LICENSE "..\License.txt"
  45. Page custom PageReinstall PageLeaveReinstall
  46. !insertmacro MUI_PAGE_COMPONENTS
  47. !insertmacro MUI_PAGE_DIRECTORY
  48. !insertmacro MUI_PAGE_INSTFILES
  49.  
  50. !define MUI_FINISHPAGE_RUN "$INSTDIR\TaskSwitchXP.exe"
  51. !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\TaskSwitchXP.chm"
  52. !define MUI_FINISHPAGE_NOREBOOTSUPPORT
  53. !insertmacro MUI_PAGE_FINISH
  54.  
  55. ; Uninstaller pages
  56. !insertmacro MUI_UNPAGE_CONFIRM
  57. !insertmacro MUI_UNPAGE_INSTFILES
  58.  
  59. ; Languages
  60. !insertmacro MUI_LANGUAGE "English"
  61.  
  62. ;-------------------------------------------------------------------------
  63. ;Reserve Files
  64.  
  65. ReserveFile "reinstall.ini"
  66. !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
  67.  
  68. ;-------------------------------------------------------------------------
  69. ; Undef this if you dont have UPX (upx.sourceforge.net)
  70. !define HAVE_UPX
  71.  
  72. !ifdef HAVE_UPX
  73.   !packhdr tmpexe.tmp "UPX -9 -q tmpexe.tmp"
  74. !endif
  75.  
  76. ;-------------------------------------------------------------------------
  77.  
  78. Name "${PRODUCT_NAME} v${PRODUCT_VERSION}"
  79. OutFile "..\${PRODUCT_NAME}_${PRODUCT_VERSION2}.exe"
  80. InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
  81. InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
  82. ShowInstDetails hide
  83. ShowUnInstDetails hide
  84.  
  85. InstType "Standard"
  86. InstType "Full"
  87.  
  88. ;-------------------------------------------------------------------------
  89. ; Variables
  90.  
  91. Var ALL_USERS
  92. Var START_SHORTCUTS
  93. Var DESKTOP_SHORTCUTS
  94.  
  95. ;-------------------------------------------------------------------------
  96. ; Version Information
  97.  
  98. VIProductVersion "${PRODUCT_VERSION3}"
  99. VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${PRODUCT_NAME}"
  100. VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${PRODUCT_VERSION3}"
  101. VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "${PRODUCT_PUBLISHER}"
  102. VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "⌐ 2004 by ${PRODUCT_PUBLISHER}"
  103. VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${PRODUCT_NAME} v${PRODUCT_VERSION} Installer"
  104. VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${PRODUCT_VERSION3}"
  105.  
  106. ;-------------------------------------------------------------------------
  107. ;Installer Sections
  108.  
  109. Section "TaskSwitchXP Core Files (required)" SecCore
  110.  
  111.   SetDetailsPrint textonly
  112.   DetailPrint "Installing TaskSwitchXP Core Files..."
  113.   SetDetailsPrint listonly
  114.  
  115.   SectionIn 1 2 RO
  116.  
  117.   ; uninstall old files
  118.   RMDir /r "$INSTDIR"
  119.  
  120.   ; uninstall old shortcuts
  121.   ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "${REG_ALL_USERS}"
  122.   IfErrors end_shortcuts
  123.   StrCmp $R0 "Yes" all_users
  124.   SetShellVarContext current
  125.   Goto start_shortcuts
  126. all_users:
  127.   SetShellVarContext all
  128. start_shortcuts:
  129.   ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "${REG_START_SHORTCUTS}"
  130.   IfErrors desktop_shortcuts
  131.   StrCmp $R0 "Yes" 0 desktop_shortcuts
  132.   RMDir /r "$SMPROGRAMS\${ICONS_GROUP}"
  133. desktop_shortcuts:
  134.   ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "${REG_DESKTOP_SHORTCUTS}"
  135.   StrCmp $R0 "Yes" 0 end_shortcuts
  136.   Delete "$DESKTOP\TaskSwitchXP.lnk"
  137.   Delete "$DESKTOP\TaskSwitchXP Configuration.lnk"
  138. end_shortcuts:
  139.  
  140.   DeleteRegValue HKCU "${RUN_REGKEY}" "TaskSwitchXP"
  141.   
  142.  
  143.   SetOutPath "$INSTDIR"
  144.   SetOverwrite on
  145.   File "..\TaskSwitchXP.exe"
  146.   File "..\ConfigTsXP.exe"
  147.   File "..\License.txt"
  148.   File "..\ReadMe.txt"
  149.   File "..\History.txt"
  150.   File "..\TaskSwitchXP.chm"
  151.  
  152.   ExecWait '"$INSTDIR\ConfigTsXP.exe" /i'
  153. SectionEnd
  154.  
  155. ;-------------------------------------------------------------------------
  156.  
  157. Section "Autostart on system startup (current user)" SecAutoStart
  158.  
  159.   SetDetailsPrint textonly
  160.   DetailPrint "Autostart on system startup (current user)..."
  161.   SetDetailsPrint listonly
  162.  
  163.   SectionIn 1 2
  164.   SetOutPath "$INSTDIR"
  165.  
  166.   WriteRegStr HKCU "${RUN_REGKEY}" "TaskSwitchXP" "$INSTDIR\TaskSwitchXP.exe"
  167. SectionEnd
  168.  
  169. ;-------------------------------------------------------------------------
  170.  
  171. SubSection /e "Additional Shortcuts" SecSh
  172.  
  173. Section "Install for all users" SecShContext
  174.   SectionIn 1 2
  175.   StrCpy $ALL_USERS "Yes"
  176. SectionEnd
  177.  
  178. Section "Start Menu Shortcuts" SecShStart
  179.   SectionIn 1 2
  180.   StrCpy $START_SHORTCUTS "Yes"
  181. SectionEnd
  182.  
  183. Section "Desktop Shortcuts" SecShDesktop
  184.   SectionIn 2
  185.   StrCpy $DESKTOP_SHORTCUTS "Yes"
  186. SectionEnd
  187.  
  188. SubSectionEnd ; SecSh
  189.  
  190. ;-------------------------------------------------------------------------
  191.  
  192. SubSection /e "Source code" SecSrc
  193.  
  194. Section "TaskSwitchXP Source" SecSrcTs
  195.  
  196.   SetDetailsPrint textonly
  197.   DetailPrint "Installing Source Code | TaskSwitchXP Source Code..."
  198.   SetDetailsPrint listonly
  199.  
  200.   SectionIn 2
  201.  
  202.   SetOutPath "$INSTDIR\Source\TaskSwitchXP"
  203.   File "TaskSwitchXP\TaskSwitchXP.sln"
  204.   File "TaskSwitchXP\TaskSwitchXP.vcproj"
  205.   File "TaskSwitchXP\main.h"
  206.   File "TaskSwitchXP\generic.h"
  207.   File "TaskSwitchXP\TaskSwitchXP.h"
  208.   File "TaskSwitchXP\stdafx.h"
  209.   File "TaskSwitchXP\registry.h"
  210.   File "TaskSwitchXP\resource.h"
  211.   File "TaskSwitchXP\main.cpp"
  212.   File "TaskSwitchXP\generic.cpp"
  213.   File "TaskSwitchXP\TaskSwitchXP.cpp"
  214.   File "TaskSwitchXP\TaskSwitchXP.rc"
  215.   SetOutPath "$INSTDIR\Source\TaskSwitchXP\res"
  216.   File "TaskSwitchXP\res\TaskSwitchXP.manifest"
  217.   File "TaskSwitchXP\res\TaskSwitchXP.ico"
  218.   File "TaskSwitchXP\res\more.ico"
  219. SectionEnd
  220.  
  221. Section "ConfigTsXP Source" SecSrcCfg
  222.  
  223.   SetDetailsPrint textonly
  224.   DetailPrint "Installing Source Code | ConfigTsXP Source Code..."
  225.   SetDetailsPrint listonly
  226.  
  227.   SectionIn 2
  228.  
  229.   SetOutPath "$INSTDIR\Source\ConfigTsXP"
  230.   File "ConfigTsXP\ConfigTsXP.sln"
  231.   File "ConfigTsXP\ConfigTsXP.vcproj"
  232.   File "ConfigTsXP\stdafx.h"
  233.   File "ConfigTsXP\main.h"
  234.   File "ConfigTsXP\ownerdrawXp.h"
  235.   File "ConfigTsXP\resource.h"
  236.   File "ConfigTsXP\main.cpp"
  237.   File "ConfigTsXP\ownerdrawXp.cpp"
  238.   File "ConfigTsXP\ConfigTsXP.rc"
  239.   SetOutPath "$INSTDIR\Source\ConfigTsXP\res"
  240.   File "ConfigTsXP\res\ConfigTsXP.manifest"
  241.   File "ConfigTsXP\res\ConfigTsXP.ico"
  242.   File "ConfigTsXP\res\ok.ico"
  243. SectionEnd
  244.  
  245. Section "NSIS Script" SecSrcInst
  246.  
  247.   SetDetailsPrint textonly
  248.   DetailPrint "Installing Source Code | NSIS Script Files..."
  249.   SetDetailsPrint listonly
  250.  
  251.   SectionIn 2
  252.  
  253.   SetOutPath "$INSTDIR\Source"
  254.   File "TaskSwitchXP.nsi"
  255.   File "reinstall.ini"
  256. SectionEnd
  257.  
  258. SubSectionEnd ; SecSrc
  259.  
  260. ;-------------------------------------------------------------------------
  261.  
  262. Section -Post
  263.  
  264.   SetDetailsPrint textonly
  265.   DetailPrint "Creating Registry Keys..."
  266.   SetDetailsPrint listonly
  267.  
  268.   SetOutPath "$INSTDIR"
  269.  
  270.   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR"
  271.   WriteRegDword HKLM "${PRODUCT_DIR_REGKEY}" "VersionMajor" "${VER_MAJOR}"
  272.   WriteRegDword HKLM "${PRODUCT_DIR_REGKEY}" "VersionMinor" "${VER_MINOR}"
  273.   WriteRegDword HKLM "${PRODUCT_DIR_REGKEY}" "VersionBuild" "${VER_BUILD}"
  274.   WriteRegDword HKLM "${PRODUCT_DIR_REGKEY}" "VersionRevision" "${VER_REVISION}"
  275.   
  276.   WriteRegStr HKLM "${APP_PATHS_REGKEY}\TaskSwitchXP.exe" "" "$INSTDIR\TaskSwitchXP.exe"
  277.   WriteRegStr HKLM "${APP_PATHS_REGKEY}\TaskSwitchXP.exe" "Path" "$INSTDIR"
  278.   WriteRegStr HKLM "${APP_PATHS_REGKEY}\ConfigTsXP.exe" "" "$INSTDIR\ConfigTsXP.exe"
  279.   WriteRegStr HKLM "${APP_PATHS_REGKEY}\ConfigTsXP.exe" "Path" "$INSTDIR"
  280.  
  281.   WriteRegExpandStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  282.   WriteRegExpandStr HKLM "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR"
  283.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  284.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\TaskSwitchXP.exe"
  285.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION2}"
  286.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Readme" "$INSTDIR\ReadMe.txt"
  287.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
  288.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "mailto:as12@bk.ru?subject=${PRODUCT_NAME}_${PRODUCT_VERSION2}&body=Hi!"
  289.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "HelpLink" "${PRODUCT_WEB_SITE}"
  290.   WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "VersionMajor" "${VER_MAJOR}"
  291.   WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "VersionMinor" "${VER_MINOR}"
  292.   WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "VersionBuild" "${VER_BUILD}"
  293.   WriteRegDword HKLM "${PRODUCT_UNINST_KEY}" "VersionRevision" "${VER_REVISION}"
  294.   WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoModify" "1"
  295.   WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoRepair" "1"
  296.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "${REG_ALL_USERS}" "$ALL_USERS"
  297.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "${REG_START_SHORTCUTS}" "$START_SHORTCUTS"
  298.   WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "${REG_DESKTOP_SHORTCUTS}" "$DESKTOP_SHORTCUTS"
  299.  
  300.   StrCmp $ALL_USERS "Yes" all_users
  301.  
  302.   SetDetailsPrint textonly
  303.   DetailPrint "Additional Shortcuts | Install only for the current user..."
  304.   SetDetailsPrint listonly
  305.  
  306.   SetShellVarContext current
  307.   Goto start_shortcuts
  308.   
  309. all_users:
  310.   SetDetailsPrint textonly
  311.   DetailPrint "Additional Shortcuts | Install for all users..."
  312.   SetDetailsPrint listonly
  313.  
  314.   SetShellVarContext all
  315.  
  316. start_shortcuts:
  317.  
  318.   StrCmp $START_SHORTCUTS "Yes" 0 desktop_shortcuts
  319.  
  320.   SetDetailsPrint textonly
  321.   DetailPrint "Additional Shortcuts | Start Menu Shortcuts..."
  322.   SetDetailsPrint listonly
  323.  
  324.   CreateDirectory "$SMPROGRAMS\${ICONS_GROUP}"
  325.   CreateShortCut "$SMPROGRAMS\${ICONS_GROUP}\TaskSwitchXP.lnk" "$INSTDIR\TaskSwitchXP.exe"
  326.   CreateShortCut "$SMPROGRAMS\${ICONS_GROUP}\TaskSwitchXP Configuration.lnk" "$INSTDIR\ConfigTsXP.exe"
  327.   CreateShortCut "$SMPROGRAMS\${ICONS_GROUP}\TaskSwitchXP Documentation.lnk" "$INSTDIR\TaskSwitchXP.chm"
  328.   WriteIniStr "$SMPROGRAMS\${ICONS_GROUP}\TaskSwitchXP Home Page.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  329.   CreateShortCut "$SMPROGRAMS\${ICONS_GROUP}\Uninstall TaskSwitchXP.lnk" "$INSTDIR\uninst.exe"
  330.  
  331.   CreateDirectory "$SMPROGRAMS\${ICONS_GROUP}\Source"
  332.   IfFileExists "$INSTDIR\Source\TaskSwitchXP\TaskSwitchXP.sln" 0 +2
  333.     CreateShortCut "$SMPROGRAMS\${ICONS_GROUP}\Source\TaskSwitchXP Solution.lnk" "$INSTDIR\Source\TaskSwitchXP\TaskSwitchXP.sln"
  334.   IfFileExists "$INSTDIR\Source\ConfigTsXP\ConfigTsXP.sln" 0 +2
  335.     CreateShortCut "$SMPROGRAMS\${ICONS_GROUP}\Source\ConfigTsXP Solution.lnk" "$INSTDIR\Source\ConfigTsXP\ConfigTsXP.sln"
  336.  
  337.   ;will only be removed if empty
  338.   SetDetailsPrint none
  339.   RMDir "$SMPROGRAMS\${ICONS_GROUP}\Source"
  340.   SetDetailsPrint lastused
  341.   
  342. desktop_shortcuts:
  343.   StrCmp $DESKTOP_SHORTCUTS "Yes" 0 end_shortcuts
  344.  
  345.   SetDetailsPrint textonly
  346.   DetailPrint "Additional Shortcuts | Desktop Shortcuts..."
  347.   SetDetailsPrint listonly
  348.  
  349.   CreateShortCut "$DESKTOP\TaskSwitchXP.lnk" "$INSTDIR\TaskSwitchXP.exe"
  350.   CreateShortCut "$DESKTOP\TaskSwitchXP Configuration.lnk" "$INSTDIR\ConfigTsXP.exe"
  351.  
  352. end_shortcuts:
  353.  
  354.   ;will only be removed if empty
  355.   SetDetailsPrint none
  356.   RMDir "$INSTDIR\Source"
  357.   SetDetailsPrint lastused
  358.  
  359.   WriteUninstaller "$INSTDIR\uninst.exe"
  360.   SetDetailsPrint both
  361. SectionEnd
  362.  
  363. ;-------------------------------------------------------------------------
  364. ;Descriptions
  365.  
  366. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  367.   !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "The core files required to use TaskSwitchXP."
  368.   !insertmacro MUI_DESCRIPTION_TEXT ${SecAutoStart} "Automatically start TaskSwitchXP when current user logged on."
  369.   !insertmacro MUI_DESCRIPTION_TEXT ${SecSh} "Adds TaskSwitchXP icons to your/common start menu and desktop for easy access."
  370.   !insertmacro MUI_DESCRIPTION_TEXT ${SecShContext} "Install TaskSwitchXP for all users that share this computer or only for the current user."
  371.   !insertmacro MUI_DESCRIPTION_TEXT ${SecShStart} "Adds TaskSwitchXP icons group to your/common start menu for easy access."
  372.   !insertmacro MUI_DESCRIPTION_TEXT ${SecShDesktop} "Adds TaskSwitchXP icons to your/common desktop for easy access."
  373.   !insertmacro MUI_DESCRIPTION_TEXT ${SecSrc} "Source code to TaskSwitchXP and all related files."
  374.   !insertmacro MUI_DESCRIPTION_TEXT ${SecSrcTs} "Source code to TaskSwitchXP."
  375.   !insertmacro MUI_DESCRIPTION_TEXT ${SecSrcCfg} "Source code to ConfigTsXP (TaskSwitchXP configuration program)."
  376.   !insertmacro MUI_DESCRIPTION_TEXT ${SecSrcInst} "NSIS 2.0 (Nullsoft Install System) script files."
  377. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  378.  
  379. ;-------------------------------------------------------------------------
  380. ;Reinstall page
  381.  
  382. Function PageReinstall
  383.  
  384.   ReadRegStr $R0 HKLM "${PRODUCT_DIR_REGKEY}" ""
  385.   StrCmp $R0 "" 0 +2
  386.   Abort
  387.  
  388.   ;Detect version
  389.   ReadRegDWORD $R0 HKLM "${PRODUCT_DIR_REGKEY}" "VersionMajor"
  390.   IntCmp $R0 ${VER_MAJOR} minor_check new_version older_version
  391. minor_check:
  392.   ReadRegDWORD $R0 HKLM "${PRODUCT_DIR_REGKEY}" "VersionMinor"
  393.   IntCmp $R0 ${VER_MINOR} build_check new_version older_version
  394. build_check:
  395.   ReadRegDWORD $R0 HKLM "${PRODUCT_DIR_REGKEY}" "VersionBuild"
  396.   IntCmp $R0 ${VER_BUILD} revision_check new_version older_version
  397. revision_check:
  398.   ReadRegDWORD $R0 HKLM "${PRODUCT_DIR_REGKEY}" "VersionRevision"
  399.   IntCmp $R0 ${VER_REVISION} same_version new_version older_version
  400.  
  401. new_version:
  402.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 1" "Text" "An older version of ${PRODUCT_NAME} is installed on your system. It's recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
  403.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 2" "Text" "Uninstall before installing"
  404.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 3" "Text" "Do not uninstall"
  405.   !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install $(^Name)."
  406.   StrCpy $R0 "1"
  407.   Goto reinst_start
  408.  
  409. older_version:
  410.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 1" "Text" "A newer version of ${PRODUCT_NAME} is already installed! It is not recommended that you install an older version. If you really want to install this older version, it's better to uninstall the current version first. Select the operation you want to perform and click Next to continue."
  411.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 2" "Text" "Uninstall before installing"
  412.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 3" "Text" "Do not uninstall"
  413.   !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install $(^Name)."
  414.   StrCpy $R0 "1"
  415.   Goto reinst_start
  416.  
  417. same_version:
  418.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 1" "Text" "$(^Name) is already installed. Select the operation you want to perform and click Next to continue."
  419.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 2" "Text" "Add/Reinstall components"
  420.   !insertmacro MUI_INSTALLOPTIONS_WRITE "reinstall.ini" "Field 3" "Text" "Uninstall ${PRODUCT_NAME}"
  421.   !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
  422.   StrCpy $R0 "2"
  423.  
  424. reinst_start:
  425.  
  426.   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "reinstall.ini"
  427. FunctionEnd
  428.  
  429.  
  430. Function PageLeaveReinstall
  431.  
  432.   FindWindow $R1 "_As12__TaskSwitchXP_MainWnd_" "" HWND_MESSAGE
  433.   IsWindow $R1 0 +3
  434.   SendMessage $R1 ${WM_DESTROY} 0 0
  435.   Sleep 200
  436.  
  437.   !insertmacro MUI_INSTALLOPTIONS_READ $R1 "reinstall.ini" "Field 2" "State"
  438.  
  439.   StrCmp $R0 "1" 0 +2
  440.     StrCmp $R1 "1" reinst_uninstall reinst_done
  441.  
  442.   StrCmp $R0 "2" 0 +3
  443.     StrCmp $R1 "1" reinst_done reinst_uninstall
  444.  
  445. reinst_uninstall:
  446.   ReadRegStr $R1 HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
  447.  
  448.   ;Run uninstaller
  449.   HideWindow
  450.  
  451.   ClearErrors
  452.   ExecWait '$R1 _?=$INSTDIR'
  453.  
  454.   IfErrors no_remove_uninstaller
  455.   IfFileExists "$INSTDIR\TaskSwitchXP.exe" no_remove_uninstaller
  456.  
  457.   Delete $R1
  458.   RMDir /r $INSTDIR
  459.  
  460. no_remove_uninstaller:
  461.  
  462.   StrCmp $R0 "2" 0 +2
  463.     Quit
  464.     
  465.   BringToFront
  466.  
  467. reinst_done:
  468.  
  469. FunctionEnd
  470.  
  471. ;-------------------------------------------------------------------------
  472. ;Installer Functions
  473.  
  474. Function .onInit
  475.  
  476.   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
  477.   IfErrors ver_abort 0
  478.  
  479.   StrCpy $R1 $R0 3
  480.   StrCmp $R1 '5.1' ver_ok
  481.   StrCmp $R1 '5.2' ver_ok ver_abort
  482.  
  483. ver_abort:
  484.   Abort
  485.   
  486. ver_ok:
  487.   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "reinstall.ini"
  488.   
  489.   StrCpy $ALL_USERS "No"
  490.   StrCpy $START_SHORTCUTS "No"
  491.   StrCpy $DESKTOP_SHORTCUTS "No"
  492. FunctionEnd
  493.  
  494. ;-------------------------------------------------------------------------
  495. ;-------------------------------------------------------------------------
  496. ;-------------------------------------------------------------------------
  497. ;Uninstaller Section
  498.  
  499. Section Uninstall
  500.  
  501.   IfFileExists "$INSTDIR\TaskSwitchXP.exe" tsxp_installed
  502.     MessageBox MB_YESNO "It does not appear that $(^Name) is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES tsxp_installed
  503.     Abort "Uninstall aborted by user"
  504. tsxp_installed:
  505.  
  506.   ReadRegStr $ALL_USERS HKLM "${PRODUCT_UNINST_KEY}" "${REG_ALL_USERS}"
  507.   ReadRegStr $START_SHORTCUTS HKLM "${PRODUCT_UNINST_KEY}" "${REG_START_SHORTCUTS}"
  508.   ReadRegStr $DESKTOP_SHORTCUTS HKLM "${PRODUCT_UNINST_KEY}" "${REG_DESKTOP_SHORTCUTS}"
  509.  
  510.   SetDetailsPrint textonly
  511.   DetailPrint "Deleting Registry Keys..."
  512.   SetDetailsPrint listonly
  513.  
  514.   DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
  515.   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  516.   DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
  517.   DeleteRegKey HKLM "${APP_PATHS_REGKEY}\TaskSwitchXP.exe"
  518.   DeleteRegKey HKLM "${APP_PATHS_REGKEY}\ConfigTsXP.exe"
  519.   DeleteRegValue HKCU "${RUN_REGKEY}" "TaskSwitchXP"
  520.   DeleteRegKey /ifempty HKLM PRODUCT_PUBLISHER_REGKEY
  521.   DeleteRegKey /ifempty HKCU PRODUCT_PUBLISHER_REGKEY
  522.  
  523.  
  524.   SetDetailsPrint textonly
  525.   DetailPrint "Deleting Start Menu and Desktop Shortcuts..."
  526.   SetDetailsPrint listonly
  527.  
  528.   StrCmp $ALL_USERS "Yes" all_users
  529.   SetShellVarContext current
  530.   Goto start_shortcuts
  531. all_users:
  532.   SetShellVarContext all
  533. start_shortcuts:
  534.   StrCmp $START_SHORTCUTS "Yes" 0 desktop_shortcuts
  535.   RMDir /r "$SMPROGRAMS\${ICONS_GROUP}"
  536. desktop_shortcuts:
  537.   StrCmp $DESKTOP_SHORTCUTS "Yes" 0 end_shortcuts
  538.   Delete "$DESKTOP\TaskSwitchXP.lnk"
  539.   Delete "$DESKTOP\TaskSwitchXP Configuration.lnk"
  540. end_shortcuts:
  541.  
  542.  
  543.   SetDetailsPrint textonly
  544.   DetailPrint "Deleting Files..."
  545.   SetDetailsPrint listonly
  546.  
  547.   Delete "$INSTDIR\uninst.exe"
  548.   Delete "$INSTDIR\ReadMe.txt"
  549.   Delete "$INSTDIR\License.txt"
  550.   Delete "$INSTDIR\History.txt"
  551.   Delete "$INSTDIR\TaskSwitchXP.chm"
  552.   Delete "$INSTDIR\ConfigTsXP.exe"
  553.   Delete "$INSTDIR\TaskSwitchXP.exe"
  554.   RMDir /r "$INSTDIR\Source"
  555.   RMDir "$INSTDIR"
  556.  
  557.   SetDetailsPrint both
  558.   SetAutoClose false
  559. SectionEnd
  560.  
  561. ;-------------------------------------------------------------------------
  562. ;Uninstaller Functions
  563.  
  564. Function un.onInit
  565.   FindWindow $R0 "_As12__TaskSwitchXP_MainWnd_" "" HWND_MESSAGE
  566.   IsWindow $R0 0 +3
  567.   SendMessage $R0 ${WM_DESTROY} 0 0
  568.   Sleep 200
  569. FunctionEnd
  570.  
  571. ;-------------------------------------------------------------------------
  572.  
  573.