You are here

need some help

1 post / 0 new
hypersonic
Offline
Last seen: 3 years 9 months ago
Joined: 2018-06-04 21:55
need some help

I need help trying to get %SYSDIR%\Tasks\MEGA folder deleted using custom code after I exit the app. The code I have doesn't seem to help and launcher just ignores any entries.

${SegmentFile}

Var CUSTOM_STARTUPEXISTS

${SegmentPrePrimary}
	; remove application initiated start up shortcut
	; `$APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\MEGAsync.lnk`
	SetShellVarContext current
	${If} ${FileExists} `$SMSTARTUP\MEGAsync.lnk`
		StrCpy $CUSTOM_STARTUPEXISTS 'Yes'
		Rename `$SMSTARTUP\MEGAsync.lnk` `$SMSTARTUP\MEGAsync.lnk-BackupBy${AppID}`
	${EndIf}

	SetShellVarContext all
	${If} ${FileExists} `$SMSTARTUP\MEGAsync.lnk`
		StrCpy $CUSTOM_STARTUPEXISTS 'Yes'
		Rename `$SMSTARTUP\MEGAsync.lnk` `$SMSTARTUP\MEGAsync.lnk-BackupBy${AppID}`
	${EndIf}	
!macroend

${SegmentPostPrimary}
	; remove application initiated start up shortcut
	SetShellVarContext current
	${If} ${FileExists} `$SMSTARTUP\MEGAsync.lnk`
		Delete `$SMSTARTUP\MEGAsync.lnk`
	${EndIf}
	${If} $CUSTOM_STARTUPEXISTS == 'Yes'
		Rename `$SMSTARTUP\MEGAsync.lnk-BackupBy${AppID}` `$SMSTARTUP\MEGAsync.lnk`
	${EndIf}

	SetShellVarContext all
	${If} ${FileExists} `$SMSTARTUP\MEGAsync.lnk`
		Delete `$SMSTARTUP\MEGAsync.lnk`
	${EndIf}
	${If} $CUSTOM_STARTUPEXISTS == 'Yes'
		Rename `$SMSTARTUP\MEGAsync.lnk-BackupBy${AppID}` `$SMSTARTUP\MEGAsync.lnk`
	${EndIf}
	
	; force clean up of start up run if no local installation present
	SetShellVarContext current
	${IfNot} ${RegistryKeyExists} 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MEGAsync'
		Delete `$SMSTARTUP\MEGAsync.lnk`
	${EndIf}

	SetShellVarContext all
	${IfNot} ${RegistryKeyExists} 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MEGAsync'
		Delete `$SMSTARTUP\MEGAsync.lnk`
	${EndIf}
	
	; remove update tasks if no local installation present
	${IfNot} ${RegistryKeyExists} 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MEGAsync'
		FindFirst $0 $1 "$SYSDIR\Tasks\MEGA\*"
			loop:
				StrCmp $1 "" done
				; Delete found task, eg. $SYSDIR\Tasks\MEGA\MEGAsync Update Task S-1-5-21-2501081379-2069658986-3569691162-1001
				nsExec::ExecToStack 'SCHTASKS.EXE /Delete /TN "$1" /F'
				FindNext $0 $1
				Goto loop
			done:
		FindClose $0
		RMDir /r "$SYSDIR\Tasks\MEGA"
	${EndIf}

	; clean up unused auto update files
	Delete '$DataDirectory\MEGAsync\update\*.*'
	Delete '$AppDirectory\MEGAsync\uninst.exe'
!macroend