pcsx2/nsis/SectionUninstaller.nsh

116 lines
3.8 KiB
Plaintext

; =======================================================================
; Shared Install Functions
; =======================================================================
Function .onInit
;prepare Advanced Uninstall log always within .onInit function
!insertmacro UNINSTALL.LOG_PREPARE_INSTALL
!include WinVer.nsh
${IfNot} ${AtLeastWinVista}
MessageBox MB_OK "Your operating system is unsupported by PCSX2. Please upgrade your operating system or install PCSX2 1.4.0."
Quit
${EndIf}
FunctionEnd
Function .onInstSuccess
;create/update log always within .onInstSuccess function
!insertmacro UNINSTALL.LOG_UPDATE_INSTALL
FunctionEnd
; =======================================================================
; Shared Uninstall Functions
; =======================================================================
; begin uninstall, could be added on top of uninstall section instead
Function un.onInit
!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
FunctionEnd
Function un.onUninstSuccess
!insertmacro UNINSTALL.LOG_END_UNINSTALL
; And remove the various install dir(s) but only if they're clean of user content:
RMDir "$DOCUMENTS\PCSX2"
RMDir "$INSTDIR\langs"
RMDir "$INSTDIR\docs"
; Force remove plugins folder due to Windows 10's wonderful UAC
; Uninstaller has Admin rights, so I guess MS still can't get UAC to behave consistently?
; I've been able to duplicate the bug in older PCSX2 installers - so it's not an NSIS 3.0 issue
; When this behavior occurs; DEV9null and USBnull left in the folder
RMDir /r "$INSTDIR\plugins"
RMDir "$INSTDIR"
FunctionEnd
; =======================================================================
; Un.Installer Sections
; =======================================================================
Section "Un.Program and Plugins ${APP_NAME}"
SetShellVarContext all
; First thing, remove the registry entry in case uninstall doesn't complete successfully
; otherwise, pcsx2 will be "confused" if it's re-installed later.
DeleteRegKey HKLM Software\PCSX2
; Please note that pointing to HKCU here is intentional. It is the only key generated by PCSX2 and *not* NSIS!
; The key stores configuration data used by the First Time Wizard (check AppConfig.cpp for details) such as DocumentsFolderMode, ect.
; Failure to delete this key can result in configuration errors
DeleteRegKey HKCU Software\PCSX2
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
; Remove uninstaller info reg key ( Wow6432Node on 64bit Windows! )
DeleteRegKey HKLM "${INSTDIR_REG_KEY}"
; Remove shortcuts, if any
Delete "$DESKTOP\${APP_NAME}.lnk"
RMDir /r "$SMPROGRAMS\PCSX2"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Langs"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Plugins"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Docs"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Shaders"
; Remove files and registry key that store PCSX2 paths configurations
SetShellVarContext current
Delete $DOCUMENTS\PCSX2\inis\PCSX2_ui.ini
SectionEnd
; /o for optional and unticked by default
Section /o "Un.Configuration files (Programs and Plugins)"
SetShellVarContext current
RMDir /r "$DOCUMENTS\PCSX2\inis\"
SectionEnd
Section /o "Un.Memory cards/savestates"
SetShellVarContext current
RMDir /r "$DOCUMENTS\PCSX2\memcards\"
RMDir /r "$DOCUMENTS\PCSX2\sstates\"
SectionEnd
; /o for optional and unticked by default
Section /o "Un.User files (Cheats, Logs, Snapshots)"
SetShellVarContext current
RMDir /r "$DOCUMENTS\PCSX2\Cheats_ws\"
RMDir /r "$DOCUMENTS\PCSX2\cheats\"
RMDir /r "$DOCUMENTS\PCSX2\logs\"
RMDir /r "$DOCUMENTS\PCSX2\snaps\"
SectionEnd
; /o for optional and unticked by default
Section /o "Un.BIOS files"
SetShellVarContext current
RMDir /r "$DOCUMENTS\PCSX2\bios\"
SectionEnd