${SegmentFile}

!define CUSTOM_OURAPPDIR '$AppDirectory\Allavsoft'

${SegmentPrePrimary}
	${If} ${RegistryKeyExists} 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{6EBED4D8-13D9-4270-8D44-B57DDB7A787C}_is1'
		${DebugMsg} "Local Allavsoft present, aborting launch."
		MessageBox MB_OK|MB_ICONSTOP "Can't run this portable app with local Allavsoft installation present.$\n Aborting launch..."
		Abort
	${Else}
		${DebugMsg} "No Local Allavsoft present. Installing Allavsoft plugins."
		nsExec::ExecToStack '"${CUSTOM_OURAPPDIR}\videodownloader.exe" /install-plugins'
	${EndIf}
!macroend

${SegmentPostPrimary}
	${DebugMsg} "Uninstall Allavsoft plugins"
	nsExec::ExecToStack '"${CUSTOM_OURAPPDIR}\videodownloader.exe" /uninstall-plugins'
	
	DeleteRegKey /ifempty HKLM SOFTWARE\Mozilla
	DeleteRegKey /ifempty HKLM 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
	DeleteRegKey /ifempty HKLM 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe'
	DeleteRegKey HKLM 'SOFTWARE\Classes\CLSID\{A87FAFBF-582F-4d90-9386-743232C1A9E5}'
!macroend
