Skip to content

Commit 410b4b1

Browse files
committed
installer (silent): optionally skip installation when files are in use
When the Git Bash is running, for example, Git for Windows cannot be upgraded. Let's introduce a flag (/SKIPIFINUSE=1) that tells the installer to please just exit, pretending to have succeeded, if we cannot upgrade because files are in use. This flag only makes sense in silent installation mode, of course, as the user would otherwise have a chance to cancel the installation herself. This option is also in effect when the installer was called from the VS installer. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 64524fe commit 410b4b1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

installer/install.iss

+18
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,15 @@ begin
581581
end;
582582
end;
583583
584+
procedure ExitProcess(uExitCode:Integer);
585+
external '[email protected] stdcall';
586+
587+
procedure ExitEarlyWithSuccess();
588+
begin
589+
DelTree(ExpandConstant('{tmp}'),True,True,True);
590+
ExitProcess(0);
591+
end;
592+
584593
function InitializeSetup:Boolean;
585594
var
586595
CurrentVersion,PreviousVersion:String;
@@ -1246,6 +1255,7 @@ function NextButtonClick(CurPageID:Integer):Boolean;
12461255
var
12471256
i:Integer;
12481257
Version:TWindowsVersion;
1258+
Msg:String;
12491259
begin
12501260
// On a silent install, if your NextButtonClick function returns False
12511261
// prior to installation starting, Setup will exit automatically.
@@ -1283,6 +1293,14 @@ begin
12831293
end;
12841294
;
12851295
end else if not Processes[i].Restartable then begin
1296+
if WizardSilent() and (ParamIsSet('SKIPIFINUSE') or ParamIsSet('VSNOTICE')) then begin
1297+
Msg:='Skipping installation because the process '+Processes[i].Name+' (pid '+IntToStr(Processes[i].ID)+') is running, using Git for Windows'+#39+' files.';
1298+
if ParamIsSet('SKIPIFINUSE') or (ExpandConstant('{log}')='') then
1299+
LogError(Msg)
1300+
else
1301+
Log(Msg);
1302+
ExitEarlyWithSuccess();
1303+
end;
12861304
SuppressibleMsgBox(
12871305
'Setup cannot continue until you close at least those applications in the list that are marked as "closing is required".'
12881306
, mbCriticalError

0 commit comments

Comments
 (0)