!include "MUI2.nsh" !include "installer.nsh" !ifndef OUTFILE !define OUTFILE "farmcontrol-server-installer.exe" !endif !ifndef VERSION !define VERSION "1.0.0" !endif !ifndef SETUP_EXE_NAME !define SETUP_EXE_NAME "Farm Control Server-Setup.exe" !endif !ifndef SETUP_ARCHIVE_NAME !define SETUP_ARCHIVE_NAME "Farm Control Server-Setup.tar.zst" !endif !ifndef SETUP_METADATA_NAME !define SETUP_METADATA_NAME "Farm Control Server-Setup.metadata.json" !endif Name "Farm Control Server" OutFile "${OUTFILE}" InstallDir "$PROGRAMFILES64\Farm Control Server" InstallDirRegKey HKLM "Software\Tom Butcher\Farm Control Server" "InstallDir" RequestExecutionLevel admin !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_LANGUAGE "English" Section "Farm Control Server" SecMain SetOutPath $INSTDIR File "${SETUP_EXE_NAME}" File "${SETUP_ARCHIVE_NAME}" File "${SETUP_METADATA_NAME}" DetailPrint "Running Farm Control Server setup..." ExecWait '"$INSTDIR\${SETUP_EXE_NAME}" /S' $0 StrCmp $0 "0" setup_ok setup_failed setup_failed: MessageBox MB_ICONSTOP "Farm Control Server setup failed (exit code $0)." Abort setup_ok: !insertmacro customInstall WriteRegStr HKLM "Software\Tom Butcher\Farm Control Server" "InstallDir" $INSTDIR WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \ "DisplayName" "Farm Control Server" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \ "DisplayVersion" "${VERSION}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \ "Publisher" "Tom Butcher" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \ "UninstallString" "$INSTDIR\Uninstall.exe" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \ "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \ "NoRepair" 1 WriteUninstaller "$INSTDIR\Uninstall.exe" SectionEnd Section "Uninstall" !insertmacro customUnInstall Delete "$INSTDIR\${SETUP_EXE_NAME}" Delete "$INSTDIR\${SETUP_ARCHIVE_NAME}" Delete "$INSTDIR\${SETUP_METADATA_NAME}" Delete "$INSTDIR\launcher.exe" Delete "$INSTDIR\Uninstall.exe" RMDir /r "$INSTDIR" DeleteRegKey HKLM "Software\Tom Butcher\Farm Control Server" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" SectionEnd