; Script generated by the HM NIS Edit Script Wizard. ;; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "Web Update Wizard (Redistributable)" !define PRODUCT_VERSION "4.0" !define PRODUCT_PUBLISHER "PowerProgrammer" !define PRODUCT_WEB_SITE "http://www.PowerProgrammer.co.uk" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\WebUpdateSvc4.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" SetCompressor /SOLID lzma RequestExecutionLevel admin ; MUI 1.67 compatible ------ !include "MUI.nsh" ; Add LogicLib !include "LogicLib.nsh" ; Add Library.nsh !include Library.nsh ; Add DumpLog function ;!include DumpLog.nsh ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON wuw4-install-blue.ico !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" !insertmacro MUI_DEFAULT MUI_WELCOMEFINISHPAGE_BITMAP "Orange.bmp" !insertmacro MUI_DEFAULT MUI_UNWELCOMEFINISHPAGE_BITMAP "Orange.bmp" XPStyle on ; Welcome page !insertmacro MUI_PAGE_WELCOME ; Directory page ;!insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page ;!insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" ; Reserve files !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "wuwinstaller.exe" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show ShowUnInstDetails show BrandingText "Web Update Wizard 4 Installer" Section "MainSection" SEC01 ;Check we have admin rights UserInfo::GetAccountType Pop $0 StrCmp $0 'Admin' +2 0 Abort "Administrator rights are required to install the Web Update Wizard Service." SetOutPath "$SYSDIR" SetOverwrite ifnewer WriteUninstaller "$SYSDIR\wuwuninst.exe" ; Stop service it it's already running DetailPrint "Stopping WebUpdateSvc4.exe if it is currently started..." nsExec::Exec '"$SYSDIR\WebUpdateSvc4.exe" -e' DetailPrint " Success!" ; Install WebUpdateSvc4.exe as shared file nsExec::Exec '"$SYSDIR\WebUpdateSvc4.exe" -e' Var /GLOBAL SVC_ALREADY_INSTALLED IfFileExists "$SYSDIR\WebUpdateSvc4.exe" 0 new_installationSvc StrCpy $SVC_ALREADY_INSTALLED 1 new_installationSvc: !insertmacro InstallLib DLL $SVC_ALREADY_INSTALLED REBOOT_NOTPROTECTED "..\..\..\MSDEV\Projects\WebUpdateSvc\Release\WebUpdateSvc4.exe" "$SYSDIR\WebUpdateSvc4.exe" $TEMP ; Install wuw4.dll as shared file Var /GLOBAL WUW4_ALREADY_INSTALLED IfFileExists "$SYSDIR\wuw4.dll" 0 new_installationWuW4 StrCpy $WUW4_ALREADY_INSTALLED 1 new_installationWuW4: !insertmacro InstallLib DLL $SVC_ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\WINDOWS\system32\wuw4.dll" "$SYSDIR\wuw4.dll" $TEMP ; Install WuWIO.exe as shared file Var /GLOBAL WUWUI_ALREADY_INSTALLED IfFileExists "$SYSDIR\WuWUI.exe" 0 new_installationWuWUI StrCpy $WUWUI_ALREADY_INSTALLED 1 new_installationWuWUI: !insertmacro InstallLib DLL $SVC_ALREADY_INSTALLED REBOOT_NOTPROTECTED "..\..\..\MSDEV\Projects\WuWUI\Release\WuWUI.exe" "$SYSDIR\WuWUI.exe" $TEMP SectionEnd Section -Post WriteUninstaller "$SYSDIR\wuwuninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$SYSDIR\WebUpdateSvc4.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$SYSDIR\wuwuninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$SYSDIR\WebUpdateSvc4.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}" ; Write registry path for WuWUI.exe DetailPrint "Writing WuWUIFolder path to HKLM..." WriteRegStr HKLM "Software\Web Update Wizard" "WuWUIFolder" "$SYSDIR\" DetailPrint " Success!" ; Maintain installcount in registry DetailPrint "Writing WuW installation count to HKLM.." Var /GLOBAL nInstallCount ReadRegDWORD $nInstallCount HKLM "Software\Web Update Wizard" "InstallCount" IntOp $nInstallCount $nInstallCount + 1 WriteRegDWORD HKLM "Software\Web Update Wizard" "InstallCount" $nInstallCount DetailPrint " (Written $nInstallCount)" ; Install and start service DetailPrint "Attempting to install WebUpdateSvc4.exe as service...." nsExec::Exec '"$SYSDIR\WebUpdateSvc4.exe" -i' DetailPrint " Success!" DetailPrint "Attempting to start WebUpdateSvc4.exe service..." nsExec::Exec '"$SYSDIR\WebUpdateSvc4.exe" -s' DetailPrint " Success!" SectionEnd ; UNINSTALLER... Function un.onUninstSuccess HideWindow IfSilent +2 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit ; Check Install counter ReadRegDWORD $nInstallCount HKLM "Software\Web Update Wizard" "InstallCount" IntOp $nInstallCount $nInstallCount - 1 WriteRegDWORD HKLM "Software\Web Update Wizard" "InstallCount" $nInstallCount ${If} $nInstallCount > 0 IfSilent +2 MessageBox MB_ICONINFORMATION|MB_OK "There are other applications on your computer which receive automatic updates via the Web Update Wizard.$\n$\nThe system will now decrement the Web Update Wizard usage counter, but the Web Update Wizard will only be uninstalled once the counter reaches zero.$\n$\n(If you really want to uninstall, just keep selecting this option in Control Panel/Add Remove Programs until the counter reaches zero.)" Abort ${EndIf} ; Ask for normal confirmation IfSilent +5 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?$\n$\n(If you uninstall $(^Name) then all applications which receive automatic updates using the Web Update Wizard by PowerProgrammer will stop receiving updates.)" IDYES +4 IntOp $nInstallCount $nInstallCount + 1 WriteRegDWORD HKLM "Software\Web Update Wizard" "InstallCount" $nInstallCount Abort FunctionEnd Section Uninstall ;Stop and uninstall the service nsExec::Exec '"$SYSDIR\WebUpdateSvc4.exe" -e' nsExec::Exec '"$SYSDIR\WebUpdateSvc4.exe" -u' ; Delete the WuWUI.exe registry location DeleteRegKey HKLM "Software\Web Update Wizard" Delete /REBOOTOK "$SYSDIR\wuw4.dll" Delete /REBOOTOK "$SYSDIR\WebUpdateSvc4.exe" Delete /REBOOTOK "$SYSDIR\WuWUI.exe" Delete "$SYSDIR\wuwuninst.exe" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" SetAutoClose true IfRebootFlag 0 noreboot IfSilent +3 MessageBox MB_YESNO "A reboot is required to finish the installation. Do you wish to reboot now?" IDNO noreboot Reboot noreboot: SectionEnd