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?
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";
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;
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With