2
0
Эх сурвалжийг харах

Add /KEEPEXEDATMSG command line param to Uninstall to make debugging it much less annoying.

Martijn Laan 5 өдөр өмнө
parent
commit
5870744f10

+ 19 - 12
Projects/Src/Setup.Uninstall.pas

@@ -47,7 +47,7 @@ var
   UninstLog: TExtUninstallLog = nil;
   UninstLog: TExtUninstallLog = nil;
   Title: String;
   Title: String;
   DidRespawn, SecondPhase: Boolean;
   DidRespawn, SecondPhase: Boolean;
-  EnableLogging, Silent, VerySilent, NoRestart: Boolean;
+  EnableLogging, Silent, VerySilent, NoRestart, KeepExeDatMsgFiles: Boolean;
   LogFilename: String;
   LogFilename: String;
   InitialProcessWnd, FirstPhaseWnd, DebugServerWnd: HWND;
   InitialProcessWnd, FirstPhaseWnd, DebugServerWnd: HWND;
   OldWindowProc: Pointer;
   OldWindowProc: Pointer;
@@ -225,19 +225,24 @@ var
 begin
 begin
   Log('Deleting Uninstall data files.');
   Log('Deleting Uninstall data files.');
 
 
-  { Truncate the .dat file to zero bytes just before relinquishing exclusive
-    access to it }
-  try
-    UninstDataFile.Seek(0);
-    UninstDataFile.Truncate;
-  except
-    { ignore any exceptions, just in case }
+  if not KeepExeDatMsgFiles then begin
+    { Truncate the .dat file to zero bytes just before relinquishing exclusive
+      access to it }
+    try
+      UninstDataFile.Seek(0);
+      UninstDataFile.Truncate;
+    except
+      { ignore any exceptions, just in case }
+    end;
   end;
   end;
+
   FreeAndNil(UninstDataFile);
   FreeAndNil(UninstDataFile);
 
 
   { Delete the .dat and .msg files }
   { Delete the .dat and .msg files }
-  DeleteFile(UninstDataFilename);
-  DeleteFile(UninstMsgFilename);
+  if not KeepExeDatMsgFiles then begin
+    DeleteFile(UninstDataFilename);
+    DeleteFile(UninstMsgFilename);
+  end;
 
 
   { Tell the first phase to terminate, then delete its .exe }
   { Tell the first phase to terminate, then delete its .exe }
   CreateUninstallDoneFile;
   CreateUninstallDoneFile;
@@ -264,7 +269,8 @@ begin
       Sleep(500);
       Sleep(500);
   end;
   end;
   UninstallExitCode := 0;
   UninstallExitCode := 0;
-  DelayDeleteFile(False, UninstExeFilename, 13, 50, 250);
+  if not KeepExeDatMsgFiles then
+    DelayDeleteFile(False, UninstExeFilename, 13, 50, 250);
   if Debugging then
   if Debugging then
     DebugNotifyUninstExe('');
     DebugNotifyUninstExe('');
   { Pre-Windows 2000 Add/Remove Programs will try to bring itself to the
   { Pre-Windows 2000 Add/Remove Programs will try to bring itself to the
@@ -322,7 +328,8 @@ begin
     else if SameText(ParamName, '/DEBUGWND=') then begin
     else if SameText(ParamName, '/DEBUGWND=') then begin
       ParamIsAutomaticInternal := True;
       ParamIsAutomaticInternal := True;
       DebugServerWnd := StrToWnd(ParamValue);
       DebugServerWnd := StrToWnd(ParamValue);
-    end;
+    end else if SameText(ParamName, '/KEEPEXEDATMSG') then { for debugging }
+      KeepExeDatMsgFiles := True;
     if not ParamIsAutomaticInternal then
     if not ParamIsAutomaticInternal then
       NewParamsForCode.Add(NewParamStr(I));
       NewParamsForCode.Add(NewParamStr(I));
   end;
   end;

+ 1 - 1
README.md

@@ -191,7 +191,7 @@ Source code tips
   `/DETACHEDMSG` command line parameter set. Afterwards copy uninst000.dat and
   `/DETACHEDMSG` command line parameter set. Afterwards copy uninst000.dat and
   uninst000.msg as setup.dat and setup.msg to the [Projects\Bin] directory in your
   uninst000.msg as setup.dat and setup.msg to the [Projects\Bin] directory in your
   issrc path. Then open the Setup project and set the command line parameters to
   issrc path. Then open the Setup project and set the command line parameters to
-  `/UNINSTMODE "/SECONDPHASE=<your issrc path\Projects\Bin\Setup.exe"` and start
+  `/UNINSTMODE /KEEPEXEDATMSG "/SECONDPHASE=<your issrc path\Projects\Bin\Setup.exe"` and start
   debugging. Note: each time setup.dat and setup.msg will be deleted if you
   debugging. Note: each time setup.dat and setup.msg will be deleted if you
   allow the uninstaller to complete so make sure to keep copies.
   allow the uninstaller to complete so make sure to keep copies.