diff --git a/installer/install.iss b/installer/install.iss index 1804d6ca93..4cca9d35f8 100644 --- a/installer/install.iss +++ b/installer/install.iss @@ -1756,6 +1756,22 @@ begin Result:=True; end; +procedure InstallAutoUpdater; +var + Res:Longint; +begin + if not Exec(ExpandConstant('{sys}\cmd.exe'),ExpandConstant('/C schtasks /Create /F /SC DAILY /TN "Git for Windows Updater" /TR "'+#39+'{app}\git-bash.exe'+#39+' --hide --no-needs-console --command=cmd\git.exe update --gui" >"{tmp}\schedule-autoupdate.log"'),'',SW_HIDE,ewWaitUntilTerminated,Res) or (Res<>0) then + LogError(ExpandConstant('Line {#__LINE__}: Unable to schedule the Git for Windows updater (see {tmp}\schedule-autoupdate.log).')); +end; + +procedure UninstallAutoUpdater; +var + Res:Longint; +begin + if not Exec(ExpandConstant('{sys}\cmd.exe'),ExpandConstant('/C schtasks /Delete /F /TN "Git for Windows Updater" >"{tmp}\remove-autoupdate.log"'),'',SW_HIDE,ewWaitUntilTerminated,Res) or (Res<>0) then + LogError(ExpandConstant('Line {#__LINE__}: Unable to remove the Git for Windows updater (see "{tmp}\remove-autoupdate.log").')); +end; + procedure CurStepChanged(CurStep:TSetupStep); var AppDir,ProgramData,DllPath,FileName,Cmd,Msg,Ico:String; @@ -2092,10 +2108,8 @@ begin Install a scheduled task to try to auto-update Git for Windows } - if IsComponentInstalled('autoupdate') then begin - if not Exec(ExpandConstant('{sys}\cmd.exe'),ExpandConstant('/C schtasks /Create /F /SC DAILY /TN "Git for Windows Updater" /TR "'+#39+'{app}\git-bash.exe'+#39+' --hide --no-needs-console --command=cmd\git.exe update --gui" >"{tmp}\schedule-autoupdate.log"'),'',SW_HIDE,ewWaitUntilTerminated,i) or (i<>0) then - LogError(ExpandConstant('Line {#__LINE__}: Unable to schedule the Git for Windows updater (see {tmp}\schedule-autoupdate.log).')); - end; + if IsComponentInstalled('autoupdate') then + InstallAutoUpdater(); { Run post-install scripts to set up system environment @@ -2327,10 +2341,8 @@ begin Remove the scheduled task to try to auto-update Git for Windows } - if IsComponentInstalled('autoupdate') then begin - if not Exec(ExpandConstant('{sys}\cmd.exe'),ExpandConstant('/C schtasks /Delete /F /TN "Git for Windows Updater" >"{tmp}\remove-autoupdate.log"'),'',SW_HIDE,ewWaitUntilTerminated,i) or (i<>0) then - LogError(ExpandConstant('Line {#__LINE__}: Unable to remove the Git for Windows updater (see "{tmp}\remove-autoupdate.log").')); - end; + if IsComponentInstalled('autoupdate') then + UninstallAutoUpdater(); { Modify the environment