[Initial]
Message=Deinstalliere MDG Git Client...
DefVar $ExitCode$
DefVar $UninstallExecutablePath$

[Aktionen]
ShowBitmap "%ScriptPath%\logo.png" "MDG Git Client"
Sub_PrepareRemove
WinBatch_Setup
Files_Cleanup
Sub_HandleExitCode

[Sub_PrepareRemove]
; Kill gpg-agent
if (processIsRunning("gpg-agent.exe"))
  comment "Killing gpg-agent..."
  Killtask "gpg-agent.exe"
  sleepSeconds 3
endif

; Retrieve Uninstall executable Path
Set $UninstallExecutablePath$ = getRegistryValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Git_is1", "UninstallString","64bit")

; Kill ssh-agent
if (processIsRunning("ssh-agent.exe"))
  comment "Killing ssh-agent..."
  Killtask "ssh-agent.exe"
  sleepSeconds 3
endif

[WinBatch_Setup]
$UninstallExecutablePath$ /VERYSILENT /SUPPRESSMSGBOXES /LOG="%opsiLogDir%\git-client-uninstall.log"


[Files_Cleanup]
delete -sf "%ProgramFilesDir%\Git\"

[Sub_HandleExitCode]
; check return code
Set $ExitCode$ = GetLastExitCode
comment "GetLastExitCode: " + $ExitCode$
if not($ExitCode$ = "0")
  LogError "Fatal: setup returned exit code " + $ExitCode$
  IsFatalError
endif
