!macro CustomCodePreInstall
	${If} ${FileExists} "$INSTDIR\App\AppInfo\appinfo.ini"
	${AndIf} ${FileExists} "$INSTDIR\Data\ccleaner.ini"
		ReadINIStr $0 "$INSTDIR\App\AppInfo\appinfo.ini" "Version" "PackageVersion"
		${VersionCompare} $0 "5.77.0.0" $R0
		${If} $R0 == 2
			WriteINIStr "$INSTDIR\Data\ccleaner.ini" "Options" "UpdateBackground" "0"
			WriteINIStr "$INSTDIR\Data\ccleaner.ini" "Options" "UpdateCheck" "0"
		${EndIf}
		${VersionCompare} $0 "6.18.10838.0" $R0
		${If} $R0 == 2
			Delete "$INSTDIR\Data\settings\CCleaner.reg"
			Delete "$INSTDIR\Data\settings\CCleanerHKLM.reg"
		${EndIf}
	${EndIf}
!macroend

!macro CustomCodePostInstall
	${If} ${FileExists} "$INSTDIR\Data\ccleaner.ini"
	${AndIfNot} ${FileExists} "$INSTDIR\Data\settings\CClean*.reg"
		CopyFiles /SILENT "$INSTDIR\App\DefaultData\settings\*.reg" "$INSTDIR\Data\settings\"
	${EndIf}
!macroend