Var bolLocalFontExists
Var bolMcAfeeCommonFilesExists
Var bolMcAfeeSharedCacheFilesExists

${SegmentFile}

${Segment.OnInit}
	Delete "$EXEDIR\Data\settings\stinger.sys"
	Delete "$EXEDIR\Data\settings\mfevtps.exe.6398.deleteme"
	
	MessageBox MB_OK|MB_ICONEXCLAMATION "WARNING! Before clicking scan, be sure to close all other running applications on your system. Stinger will force close some processes including unrelated apps like FileZilla which can cause a loss of data. After scanning, run Stinger Portable a second time and then close the application (without clicking scan) so that files can be properly cleaned up. Some files may be left behind on Windows XP. Selecting to scan for rootkits (off by default) will result in a Validation Service being installed to the local PC and then left behind. It can be removed with the McAfee Consumer Product Removal tool (MCPR)."
	
	${If} ${FileExists} "$PROGRAMFILES64\stinger\*.ttf"
	${OrIf} ${FileExists} "$PROGRAMFILES32\stinger\*.ttf"
	${OrIf} ${FileExists} "$PROGRAMFILES\stinger\*.ttf"
		StrCpy $bolLocalFontExists true
	${Else}
		StrCpy $bolLocalFontExists false
	${EndIf}
	
	${If} ${FileExists} "$PROGRAMFILES64\Common Files\McAfee\SystemCore\*.*"
	${OrIf} ${FileExists} "$PROGRAMFILES32\Common Files\McAfee\SystemCore\*.*"
	${OrIf} ${FileExists} "$PROGRAMFILES\Common Files\McAfee\SystemCore\*.*"
		StrCpy $bolMcAfeeCommonFilesExists true
	${Else}
		StrCpy $bolMcAfeeCommonFilesExists false
	${EndIf}
	
	${If} ${FileExists} "$COMMONPROGRAMDATA\McAfee\SharedCache\*.*"
		StrCpy $bolMcAfeeSharedCacheFilesExists true
	${Else}
		StrCpy $bolMcAfeeSharedCacheFilesExists false
	${EndIf}
!macroend

${SegmentPost}
	${If} $bolLocalFontExists == false
		RMDir /r "$PROGRAMFILES64\Common Files\McAfee\SystemCore"
		RMDir /r "$PROGRAMFILES32\Common Files\McAfee\SystemCore"
		RMDir /r "$PROGRAMFILES\Common Files\McAfee\SystemCore"
		RMDir "$PROGRAMFILES64\Common Files\McAfee"
		RMDir "$PROGRAMFILES32\Common Files\McAfee"
		RMDir "$PROGRAMFILES\Common Files\McAfee"
	${EndIf}
	
	${If} $bolMcAfeeSharedCacheFilesExists == false
		RMDir /r "$COMMONPROGRAMDATA\McAfee\SharedCache"
		RMDir "$COMMONPROGRAMDATA\McAfee"
	${EndIf}

	SetRegView 64
	ReadRegStr $0 HKLM "SOFTWARE\McAfee\Certs" "SearchPath"
	${If} $0 == "$PROGRAMFILES64\stinger"
	${OrIf} $0 == "$PROGRAMFILES32\stinger"
	${OrIf} $0 == "$PROGRAMFILES\stinger"
		DeleteRegValue HKLM "SOFTWARE\McAfee\Certs" "SearchPath"
	${EndIf}
	DeleteRegKey /ifempty HKLM "SOFTWARE\McAfee\Certs"
	DeleteRegKey /ifempty HKLM "SOFTWARE\McAfee"
	SetRegView 32
	
	${If} ${FileExists} "$PROGRAMFILES64\stinger\*.ttf"
	${OrIf} ${FileExists} "$PROGRAMFILES32\stinger\*.ttf"
	${OrIf} ${FileExists} "$PROGRAMFILES\stinger\*.ttf"
		${If} $bolLocalFontExists == false
			Sleep 2000
			Delete "$PROGRAMFILES64\stinger\*.ttf"
			Delete "$PROGRAMFILES32\stinger\*.ttf"
			Delete "$PROGRAMFILES\stinger\*.ttf"
			RMDir "$PROGRAMFILES64\stinger"
			RMDir "$PROGRAMFILES32\stinger"
			RMDir "$PROGRAMFILES\stinger"
			${If} ${FileExists} "$PROGRAMFILES64\stinger\*.ttf"
			${OrIf} ${FileExists} "$PROGRAMFILES32\stinger\*.ttf"
			${OrIf} ${FileExists} "$PROGRAMFILES\stinger\*.ttf"
				${If} $bolLocalFontExists == false
					Sleep 4000
					Delete "$PROGRAMFILES64\stinger\*.ttf"
					Delete "$PROGRAMFILES32\stinger\*.ttf"
					Delete "$PROGRAMFILES\stinger\*.ttf"
					RMDir "$PROGRAMFILES64\stinger"
					RMDir "$PROGRAMFILES32\stinger"
					RMDir "$PROGRAMFILES\stinger"
					${If} ${FileExists} "$PROGRAMFILES64\stinger\*.ttf"
					${OrIf} ${FileExists} "$PROGRAMFILES32\stinger\*.ttf"
					${OrIf} ${FileExists} "$PROGRAMFILES\stinger\*.ttf"
						Sleep 4000
					${EndIf}
				${EndIf}
			${EndIf}
		${EndIf}
	${EndIf}
!macroend