Skip to content

Commit 539465e

Browse files
authored
Merge pull request #312 from dscho/avoid-AutoRun-when-spawning-cmd-from-the-installer
installer: when spawning `cmd`, disable `AutoRun`
2 parents d4840a9 + c27eb89 commit 539465e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

installer/install.iss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -680,15 +680,15 @@ begin
680680
OutPath:=ExpandConstant('{tmp}\config-set.out');
681681
ErrPath:=ExpandConstant('{tmp}\config-set.err');
682682
if (Value=#0) then begin
683-
if Exec(ExpandConstant('{cmd}'),'/C .\{#MINGW_BITNESS}\bin\git.exe config --system --unset '+Key+' >'+#34+OutPath+#34+' 2>'+#34+ErrPath+#34,
683+
if Exec(ExpandConstant('{cmd}'),'/D /C .\{#MINGW_BITNESS}\bin\git.exe config --system --unset '+Key+' >'+#34+OutPath+#34+' 2>'+#34+ErrPath+#34,
684684
AppDir,SW_HIDE,ewWaitUntilTerminated,i) And ((i=0) Or (i=5)) then
685685
// exit code 5 means it was already unset, so that's okay
686686
Result:=True
687687
else begin
688688
LogError('Unable to unset system config "'+Key+'": exit code '+IntToStr(i)+#13+#10+ReadFileAsString(OutPath)+#13+#10+'stderr:'+#13+#10+ReadFileAsString(ErrPath));
689689
Result:=False
690690
end
691-
end else if Exec(ExpandConstant('{cmd}'),'/C .\{#MINGW_BITNESS}\bin\git.exe config --system '+ShellQuote(Key)+' '+ShellQuote(Value)+' >'+#34+OutPath+#34+' 2>'+#34+ErrPath+#34,
691+
end else if Exec(ExpandConstant('{cmd}'),'/D /C .\{#MINGW_BITNESS}\bin\git.exe config --system '+ShellQuote(Key)+' '+ShellQuote(Value)+' >'+#34+OutPath+#34+' 2>'+#34+ErrPath+#34,
692692
AppDir,SW_HIDE,ewWaitUntilTerminated,i) And (i=0) then
693693
Result:=True
694694
else begin
@@ -729,7 +729,7 @@ begin
729729
end;
730730
731731
TmpFile:=ExpandConstant('{tmp}\git-config-get.txt');
732-
if not Exec(ExpandConstant('{cmd}'),'/C .\{#MINGW_BITNESS}\bin\git.exe config -l -z '+ExtraOptions+' >'+#34+TmpFile+#34,
732+
if not Exec(ExpandConstant('{cmd}'),'/D /C .\{#MINGW_BITNESS}\bin\git.exe config -l -z '+ExtraOptions+' >'+#34+TmpFile+#34,
733733
AppDir,SW_HIDE,ewWaitUntilTerminated,i) then
734734
LogError('Unable to get system config');
735735
@@ -917,7 +917,7 @@ begin
917917
if Result or (CountDots(CurrentVersion)>3) or (CountDots(PreviousVersion)>3) then begin
918918
// maybe the previous version was a prerelease (prereleases have five numbers: v2.24.0-rc1.windows.1 reduces to '2.24.0.1.1')?
919919
if (RegQueryStringValue(HKEY_LOCAL_MACHINE,'Software\GitForWindows','InstallPath',Path))
920-
and (Exec(ExpandConstant('{cmd}'),'/c ""'+Path+'\cmd\git.exe" version >"'+ExpandConstant('{tmp}')+'\previous.version""','',SW_HIDE,ewWaitUntilTerminated,i))
920+
and (Exec(ExpandConstant('{cmd}'),'/d /c ""'+Path+'\cmd\git.exe" version >"'+ExpandConstant('{tmp}')+'\previous.version""','',SW_HIDE,ewWaitUntilTerminated,i))
921921
and (i=0) then begin
922922
CurrentVersion:='{#GIT_VERSION}';
923923
PreviousVersion:=ReadFileAsString(ExpandConstant('{tmp}\previous.version'));
@@ -1123,7 +1123,7 @@ function IsOriginalUserAdmin():Boolean;
11231123
var
11241124
ResultCode:Integer;
11251125
begin
1126-
if not ExecAsOriginalUser(ExpandConstant('{cmd}'),ExpandConstant('/c net session >"{tmp}\net-session.txt"'),'',SW_HIDE,ewWaitUntilTerminated,ResultCode) then
1126+
if not ExecAsOriginalUser(ExpandConstant('{cmd}'),ExpandConstant('/d /c net session >"{tmp}\net-session.txt"'),'',SW_HIDE,ewWaitUntilTerminated,ResultCode) then
11271127
ResultCode:=-1;
11281128
Result:=(ResultCode=0);
11291129
end;
@@ -1153,7 +1153,7 @@ begin
11531153
end else begin
11541154
// maybe rights assigned through group policy without enabling developer mode?
11551155
// let's test by creating a symbolic link
1156-
ExecAsOriginalUser(ExpandConstant('{cmd}'),ExpandConstant('/c mklink /d "{tmp}\symbolic link" "{tmp}" >"{tmp}\symlink test.txt"'),'',SW_HIDE,ewWaitUntilTerminated,ResultCode);
1156+
ExecAsOriginalUser(ExpandConstant('{cmd}'),ExpandConstant('/d /c mklink /d "{tmp}\symbolic link" "{tmp}" >"{tmp}\symlink test.txt"'),'',SW_HIDE,ewWaitUntilTerminated,ResultCode);
11571157
Result:=DirExists(ExpandConstant('{tmp}\symbolic link'));
11581158
end;
11591159
end;
@@ -2275,7 +2275,7 @@ begin
22752275
if not FileExists(ExpandConstant('{tmp}\blocked-file-util.exe')) then
22762276
ExtractTemporaryFile('blocked-file-util.exe');
22772277
LogPath:=ExpandConstant('{tmp}\blocking-pids.log');
2278-
Cmd:='/C ""'+ExpandConstant('{tmp}\blocked-file-util.exe')+'" blocking-pids "'+AppDir+'" 2>"'+LogPath+'""';
2278+
Cmd:='/D /C ""'+ExpandConstant('{tmp}\blocked-file-util.exe')+'" blocking-pids "'+AppDir+'" 2>"'+LogPath+'""';
22792279
if not Exec(ExpandConstant('{sys}\cmd.exe'),Cmd,'',SW_HIDE,ewWaitUntilTerminated,Res) or (Res<>0) then begin
22802280
Msg:='Skipping installation because '+AppDir+' is still in use:'+#13+#10+ReadFileAsString(LogPath);
22812281
if ParamIsSet('SKIPIFINUSE') or (ExpandConstant('{log}')='') then
@@ -2595,7 +2595,7 @@ begin
25952595
'</Task>',False);
25962596
LogPath:=ExpandConstant('{tmp}\remove-autoupdate.log');
25972597
ErrPath:=ExpandConstant('{tmp}\remove-autoupdate.err');
2598-
if not Exec(ExpandConstant('{sys}\cmd.exe'),ExpandConstant('/C schtasks /Create /F /TN "Git for Windows Updater" /XML "'+XMLPath+'" >"'+LogPath+'" 2>"'+ErrPath+'"'),'',SW_HIDE,ewWaitUntilTerminated,Res) or (Res<>0) then
2598+
if not Exec(ExpandConstant('{sys}\cmd.exe'),ExpandConstant('/D /C schtasks /Create /F /TN "Git for Windows Updater" /XML "'+XMLPath+'" >"'+LogPath+'" 2>"'+ErrPath+'"'),'',SW_HIDE,ewWaitUntilTerminated,Res) or (Res<>0) then
25992599
LogError(ExpandConstant('Line {#__LINE__}: Unable to schedule the Git for Windows updater (output: '+ReadFileAsString(LogPath)+', errors: '+ReadFileAsString(ErrPath)+').'));
26002600
end;
26012601
@@ -2606,7 +2606,7 @@ var
26062606
begin
26072607
LogPath:=ExpandConstant('{tmp}\remove-autoupdate.log');
26082608
ErrPath:=ExpandConstant('{tmp}\remove-autoupdate.err');
2609-
if not Exec(ExpandConstant('{sys}\cmd.exe'),ExpandConstant('/C schtasks /Delete /F /TN "Git for Windows Updater" >"'+LogPath+'" 2>"'+ErrPath+'"'),'',SW_HIDE,ewWaitUntilTerminated,Res) or (Res<>0) then
2609+
if not Exec(ExpandConstant('{sys}\cmd.exe'),ExpandConstant('/D /C schtasks /Delete /F /TN "Git for Windows Updater" >"'+LogPath+'" 2>"'+ErrPath+'"'),'',SW_HIDE,ewWaitUntilTerminated,Res) or (Res<>0) then
26102610
LogError(ExpandConstant('Line {#__LINE__}: Unable to remove the Git for Windows updater (output: '+ReadFileAsString(LogPath)+', errors: '+ReadFileAsString(ErrPath)+').'));
26112611
end;
26122612

0 commit comments

Comments
 (0)