2019-01-26 03:45:37 +00:00
; Copyright (C) 2019 PCSX2 Team
2017-03-13 22:46:15 +00:00
Function UninstallPrevious
2020-09-23 11:51:08 +00:00
; This will become the primary version check
2017-03-13 22:46:15 +00:00
ReadRegStr $R1 HKLM "${INSTDIR_REG_KEY}" "DisplayVersion"
2020-05-05 19:02:07 +00:00
ReadRegStr $R2 HKLM Software\PCSX2 "Install_Dir"
${If} $R1 != ""
${AndIf} $R2 != ""
Goto UserPrompt
${EndIf}
2017-03-13 22:46:15 +00:00
; If all cases return null, our work here is done.
${If} $R2 == ""
2020-09-23 11:51:08 +00:00
Return
2017-03-13 22:46:15 +00:00
${EndIf}
2020-05-05 19:02:07 +00:00
UserPrompt:
2017-03-13 22:46:15 +00:00
; Installing another version
2020-09-22 19:24:04 +00:00
MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "An existing version of PCSX2 has been detected and will be REMOVED. The config folder in Documents will be duplicated (if it exists) and renamed as PCSX2_backup. Backup any important files and click OK to uninstall PCSX2 or Cancel to abort the setup." /SD IDOK IDOK SetUninstPath IDCANCEL false
2017-03-16 23:01:45 +00:00
false:
Quit
2017-03-13 22:46:15 +00:00
SetUninstPath:
2017-03-16 23:01:45 +00:00
SetOutPath "$DOCUMENTS"
CopyFiles /SILENT "$DOCUMENTS\PCSX2" "$DOCUMENTS\PCSX2_backup"
RMDir /r "$DOCUMENTS\PCSX2"
2020-05-05 19:02:07 +00:00
${If} $R1 != ""
2017-03-13 22:46:15 +00:00
Goto ExecNormal
${EndIf}
ExecNormal:
SetOutPath "$TEMP"
2020-05-05 19:02:07 +00:00
CopyFiles /SILENT /FILESONLY "$R2\Uninst-pcsx2.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2.exe" /S _?=$R2'
2017-03-13 22:46:15 +00:00
Delete "$TEMP\Uninst-pcsx2.exe"
2017-03-16 23:01:45 +00:00
Return
2020-05-05 19:02:07 +00:00
FunctionEnd