Search code examples
inno-setupuninstallation

Clarification about using RunOnceId in [UninstallRun] section of Inno Setup script


Here is my [UninstallRun] section:

[UninstallRun]
Filename: {dotnet40}\regasm.exe; Parameters: /u MSAToolsLibrary_x86.dll; WorkingDir: {app}; Flags: runhidden;
Filename: {dotnet4064}\regasm.exe; Parameters: /u MSAToolsLibrary_x64.dll; WorkingDir: {app}; Flags: runhidden; Check: IsWin64;
Filename: {dotnet40}\regasm.exe; Parameters: /u MSAToolsGMailLibrary_86.dll; WorkingDir: {app}\MSAToolsGMailLibrary; Flags: runhidden
Filename: {dotnet4064}\regasm.exe; Parameters: /u MSAToolsGMailLibrary_64.dll; WorkingDir: {app}\MSAToolsGMailLibrary; Flags: runhidden; Check: IsWin64;

When I compile with Inno Setup 6.1.1 I get this warning:

Warning: There are [UninstallRun] section entries without a RunOnceId parameter. By assigning a string to RunOnceId, you can ensure that a particular [UninstallRun] entry will only be executed once during uninstallation. See the "[UninstallRun]" topic in help file for more information.

I have looked up the help for RunOnceId where it states:

Valid only in an [UninstallRun] section. If the same application is installed more than once, "run" entries will be duplicated in the uninstall log file. By assigning a string to RunOnceId, you can ensure that a particular [UninstallRun] entry will only be executed once during uninstallation. For example, if two or more "run" entries in the uninstall log have a RunOnceId setting of "DelService", only the latest entry with a RunOnceId setting of "DelService" will be executed; the rest will be ignored. Note that RunOnceId comparisons are case-sensitive. If you don't assign a string to RunOnceId, the compiler will warn you about this, which can be disabled using MissingRunOnceIdsWarning.

I can see that I can switch off the warning. But I wanted to know if I really needed to use this parameter in my setup because I never have done so until now.


Solution

  • You should use the parameter, as the warning suggests.

    If you don't, for every upgrade (unless your installer uninstalls the previous version), a new execution of your [UninstallRun] commands will be queued. So if you install and then upgrade 9 times, all your uninstall commands will be executed 10 times, when uninstalling. Of course, in your case, that only means each your regasm /u command will fail 9 times. Not a big deal, but if user inspects an uninstaller log (in case they have problems), they will see lot of failures, what may mislead them.

    Note that you cannot fix this retrospectively. The uninstall commands queued by previous installers will still be executed for each past installation. But again, were it a major problem, you would probably have noticed already.