Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force InnoSetup to create an uninstall log file

I'm using InnoSetup for creating my application installers and I set the "SetupLogging=yes" flag to always create a setup-log file in the %TEMP% directory. This works fine for the installation procedure. Unfortunately, InnoSetup will not create such a log file when I uninstall the application.

Is there a flag / possibility to force InnoSetup to also create an uninstall log file?

like image 364
mkva Avatar asked Mar 25 '10 08:03

mkva


4 Answers

I've been able to have the installer write a log file by adding the "/log" option as a parameter to its exe in the Icons section:

[Setup]
...
SetupLogging=yes
...

[Icons]
...
Name: {group}\Uninstall; Filename: {uninstallexe}; Parameters: "/log";
like image 64
Jimm Domingo Avatar answered Oct 31 '22 01:10

Jimm Domingo


I wrote the following code to implement @mlaan's answer (appending "/log" to the uninstall strings in the registry). Note that I'm only checking HKLM. You could add lines to check HKCU instead or as well.

#define MyAppID "{3D97CC33-75B0-4D86-8533-B213E5FF4046}"

[Setup]
AppId={{#MyAppID}

[Code]
procedure AppendStringToRegValue(const RootKey: integer; const SubKeyName, ValueName, StringToAppend: string);
var
  OldValue: string;  
  NewValue: string;  
  RootKeyString: string;
begin
  case RootKey of
    HKLM: 
      RootKeyString := 'HKLM';
    HKCU: 
      RootKeyString := 'HKCU';
  else 
    RootKeyString := 'RootKey ' + IntToStr(RootKey);
  end;

  if RegQueryStringValue( RootKey, SubKeyName, ValueName, OldValue ) then
  begin
    NewValue := OldValue + StringToAppend
    if RegWriteStringValue( RootKey, SubKeyName, ValueName, NewValue ) then
      Log('Updated ' + RootKeyString + '\' + SubKeyName + '\' + ValueName + '. New Value = [' + NewValue + '].')
    else
      Log('Could not write to ' + RootKeyString + '\' + SubKeyName + '\' + ValueName + '. Value remains [' + OldValue + '].' )
  end
  else
    Log('Could not read from ' + RootKeyString + '\' + SubKeyName + '\' + ValueName + '.' );
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  OldValue: string;  
  NewValue: string;  
  UninstallSubKeyName:  string;
begin
  if CurStep = ssPostInstall then
  begin
    { Modify uninstall registry entries to add "/log" parameter for uninstall }
    UninstallSubKeyName  := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppID}_is1'
    AppendStringToRegValue(HKLM, UninstallSubKeyName, 'UninstallString', ' /log')
    AppendStringToRegValue(HKLM, UninstallSubKeyName, 'QuietUninstallString', ' /log')
  end;
end;
like image 40
Mark Berry Avatar answered Oct 31 '22 01:10

Mark Berry


I am not expert but in my case i noticed that during the install, in the install directory was also created a file with the following name:

 unins000.exe

So, to create the log file for uninstall, i just need to call the file from command line giving the path\name for the log, in my case disinstallazione.log:

unins000.exe  /log="C:\disinstallazione.log"

That's how i could understand what's happening during uninstallation.


P.S. also in my case i have

SetupLogging=yes
like image 24
fresko Avatar answered Oct 31 '22 00:10

fresko


No, you would have to use [Code] to update the Uninstall registry key to include a /LOG parameter in the UninstallString value.

The registry key will be either HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall(YourAppID)_is1 or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall(YourAppID)_is1

Do this at the end on the installation, and only when it succeeded. For example inside an CurStepChanged event function with CurStep = ssPostInstall.

like image 44
mlaan Avatar answered Oct 31 '22 01:10

mlaan