mkva
mkva

Reputation: 444

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?

Upvotes: 5

Views: 6938

Answers (5)

Mark Berry
Mark Berry

Reputation: 19092

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
  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;

Upvotes: 6

user4348079
user4348079

Reputation: 1

Put these two lines in the [Setup] section of your InnoSetup script

[Setup]
SetupLogging=yes
UninstallLogMode=append

After uninstalling, look in the temp folder for your logs. In Windows7 that location would be

C:\Users\<UserName>\AppData\Local\Temp

You will find a file named something like

Setup Log 2014-12-10 #001.txt

That is your Inno Setup Log file.

Upvotes: -3

fresko
fresko

Reputation: 2062

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

Upvotes: 3

Jimm Domingo
Jimm Domingo

Reputation: 203

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";

Upvotes: 5

mlaan
mlaan

Reputation: 667

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.

Upvotes: 2

Related Questions