xenadmin/installer-xcp-ng/installer.nsi

187 lines
5.6 KiB
Plaintext
Raw Normal View History

; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "XCP-ng Center"
!define PRODUCT_VERSION "vNext"
!define PRODUCT_PUBLISHER "XCP-ng Project"
!define PRODUCT_WEB_SITE "https://xcp-ng.org/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\XCP-ng Center.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
; MUI 1.67 compatible ------
!include "MUI.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "AppIcon.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "wizard.bmp"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "license.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\XCP-ng Center.exe"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
!define StrTrimNewLines "!insertmacro StrTrimNewLines Init ''"
!define UnStrTrimNewLines "!insertmacro StrTrimNewLines Init Un"
!macro StrTrimNewLines OutVar String
!verbose push
!verbose 3
!if "${OutVar}" == "Init"
!undef ${String}StrTrimNewLines
!define ${String}StrTrimNewLines "!insertmacro StrTrimNewLines "
!if "${String}" != ""
Function un.StrTrimNewLines
!else
Function StrTrimNewLines
!endif
!insertmacro StrTrimNewLines Func ''
FunctionEnd
!else if "${OutVar}" == "Func"
Exch $0
Push $1
n: StrCpy $1 $0 1 -1
StrCmp $1 '$\r' +2
StrCmp $1 '$\n' +1 e
StrCpy $0 $0 -1
Goto n
e: Pop $1
Exch $0
!else
Push "${String}"
!ifdef __UNINSTALL__
Call un.StrTrimNewLines
!else
Call StrTrimNewLines
!endif
Pop "${OutVar}"
!endif
!verbose pop
!macroend
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\XCP-ng Center"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Function .onInit
ClearErrors
SetRegView 32
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{45CFD130-100D-4868-BE0C-EA772261E950}" "DisplayName"
${If} ${Errors}
${Else}
MessageBox MB_OK|MB_ICONSTOP "You have an older MSI-based install of XCP-ng Center installed. You must uninstall it first before running this setup."
Quit
${EndIf}
FunctionEnd
Section "MainSection" SEC01
InitPluginsDir
SetOutPath "$PLUGINSDIR"
File drop.zip
SetOutPath "$INSTDIR"
nsisunz::UnzipToStack "$PLUGINSDIR\drop.zip" "$INSTDIR"
Pop $0
StrCmp $0 "success" ok
DetailPrint "$0" ;print error message to log
Goto skiplist
ok:
next:
Pop $0
DetailPrint "Unzipped File: $0"
FileOpen $4 "$INSTDIR\install.log" a
FileSeek $4 0 END
FileWrite $4 "$0$\r$\n"
FileClose $4 ; and close the file
StrCmp $0 "" 0 next ; pop strings until a blank one arrives
skiplist:
CreateDirectory "$SMPROGRAMS\XCP-ng Center"
CreateShortCut "$SMPROGRAMS\XCP-ng Center\XCP-ng Center.lnk" "$INSTDIR\XCP-ng Center.exe"
CreateShortCut "$DESKTOP\XCP-ng Center.lnk" "$INSTDIR\XCP-ng Center.exe"
SectionEnd
Section -AdditionalIcons
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\XCP-ng Center\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\XCP-ng Center\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\XCP-ng Center.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\XCP-ng Center.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
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
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
${UnStrTrimNewLines}
Section Uninstall
FileOpen $0 "$INSTDIR\install.log" r
delete_loop:
IfErrors exit_loop
FileRead $0 $1
${UnStrTrimNewLines} $2 $1
StrCmp $2 "" exit_loop 0
DetailPrint "$INSTDIR\$2"
Delete "$INSTDIR\$2"
Goto delete_loop
exit_loop:
FileClose $0
Delete "$INSTDIR\install.log"
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$SMPROGRAMS\XCP-ng Center\Uninstall.lnk"
Delete "$SMPROGRAMS\XCP-ng Center\Website.lnk"
Delete "$DESKTOP\XCP-ng Center.lnk"
Delete "$SMPROGRAMS\XCP-ng Center\XCP-ng Center.lnk"
RMDir "$SMPROGRAMS\XCP-ng Center"
; Removing some known directories
RMDir "$INSTDIR\zh-CN"
RMDir "$INSTDIR\ja"
RMDir "$INSTDIR"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd