@@ -1731,7 +1731,10 @@ begin
1731
1731
Exit;
1732
1732
end ;
1733
1733
1734
- TmpFile:=ExpandConstant(' {tmp}\editor-test.txt' );
1734
+ // We are _not_ writing into the `{tmp}` directory, because it is private to the
1735
+ // elevated process and cannot be written to by the non-elevated editor.
1736
+ // Instead, we write _next_ to the `{tmp}` directory.
1737
+ TmpFile:=ExpandConstant(' {tmp}-editor-test.txt' );
1735
1738
InputText:=' Please modify this text, e.g. delete it, then save it and exit the editor.'
1736
1739
SaveStringToFile(TmpFile,InputText,False);
1737
1740
@@ -1744,17 +1747,20 @@ begin
1744
1747
if not ShellExecAsOriginalUser(' ' ,CustomEditorPath,CustomEditorOptions+' "' +TmpFile+' "' ,' ' ,Show,ewWaitUntilTerminated,Res) then begin
1745
1748
Wizardform.NextButton.Enabled:=False;
1746
1749
SuppressibleMsgBox(' Could not launch: "' +CustomEditorPath+' "' ,mbError,MB_OK,IDOK);
1750
+ DeleteFile(TmpFile); // ignore errors, if any
1747
1751
Exit;
1748
1752
end ;
1749
1753
if (Res<>0 ) then begin
1750
1754
Wizardform.NextButton.Enabled:=False;
1751
1755
SuppressibleMsgBox(' Exited with failure: "' +CustomEditorPath+' "' ,mbError,MB_OK,IDOK);
1756
+ DeleteFile(TmpFile); // ignore errors, if any
1752
1757
Exit;
1753
1758
end ;
1754
1759
1755
1760
if not LoadStringFromFile(TmpFile,OutputText) then begin
1756
1761
Wizardform.NextButton.Enabled:=False;
1757
1762
SuppressibleMsgBox(' Could not read "' +TmpFile+' "' ,mbError,MB_OK,IDOK);
1763
+ DeleteFile(TmpFile); // ignore errors, if any
1758
1764
Exit;
1759
1765
end ;
1760
1766
0 commit comments