Skip to content

Commit

Permalink
installer: refactor (de-)registering the auto updater
Browse files Browse the repository at this point in the history
In the next steps, we will complexify that code, so let's
compartmentalize the damage to dedicated procedures.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Oct 26, 2017
1 parent 4b26e20 commit 9549f52
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9549f52

Please sign in to comment.