Change the default name of an Inno-Setup uninstall

2019-04-05 23:56发布

问题:

I need to install a couple of installers in the same directory so it conflicts with the inno setup uninstaller name unins000.exe and unins000.dat

Is there a way to change the default name of an Inno-Setup uninstaller?

回答1:

This is similar to Elektrostudios' answer, and is what worked for me:

    Filename: {cmd}; Parameters: "/C Mkdir ""{app}\Uninstallers\{#MyAppName}"""; Flags: RunHidden WaitUntilTerminated
    Filename: {cmd}; Parameters: "/C Move ""{app}\unins000.exe"" ""{app}\Uninstallers\{#MyAppName} - uninstall.exe"""; StatusMsg: Installing {#MyAppName}...; Flags: RunHidden WaitUntilTerminated
    Filename: {cmd}; Parameters: "/C Move ""{app}\unins000.dat"" ""{app}\Uninstallers\{#MyAppName} - uninstall.dat"""; StatusMsg: Installing {#MyAppName}...; Flags: RunHidden WaitUntilTerminated
    Filename: {cmd}; Parameters: "/C Move ""{app}\unins000.msg"" ""{app}\Uninstallers\{#MyAppName} - uninstall.msg"""; StatusMsg: Installing {#MyAppName}...; Flags: RunHidden WaitUntilTerminated
    Filename: REG.exe; Parameters: "ADD ""HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Windows 8 ContextMenu - {#MyAppName}_is1"" /V ""UninstallString"" /T ""REG_SZ"" /D ""\""{app}\Uninstallers\{#MyAppName} - uninstall.exe\"""" /F"; StatusMsg: Installing {#MyAppName}...; Flags: RunHidden WaitUntilTerminated
    Filename: REG.exe; Parameters: "ADD ""HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Windows 8 ContextMenu - {#MyAppName}_is1"" /V ""QuietUninstallString"" /T ""REG_SZ"" /D ""\""{app}\Uninstallers\{#MyAppName} - uninstall.exe\"" /SILENT"" /F"; StatusMsg: Installing {#MyAppName}...; Flags: RunHidden WaitUntilTerminated

Using Windows 7, I discovered that the "Move" command wouldn't work unless I had somewhere to move the files to first, meaning that I had to add the mkdir line at the top. Also, the uninstaller wouldn't work without the .msg file moved as well, so I followed the pattern and added that line too.

I didn't bother to change "Windows 8" to "Windows 7" but it didn't make any difference, so I'm leaving it alone. If there's a problem with that I'm unaware of, I'm sure someone will indicate such in a comment.

{#MyAppName} is, of course, the constant defined at the top of the ISS file declaring the name of the application. Your constant may be defined differently, so you'll need to change it to match where necessary.



回答2:

No. 'unins' is hard-coded in the name generation procedure of the executable, data and msg files, in GenerateUninstallInfoFilename' procedure in 'install.pas' of inno-setup sources.

GenerateFilenames sub procedure has this:

BaseFilename := AddBackslash(BaseDir) + Format('unins%.3d', [I]);
UninstallExeFilename := BaseFilename + '.exe';
..

Where 'I' is an integer and 'BaseDir' is derived from UninstallFilesDir which you can change.



回答3:

Inno does this automatically when it detects a different application being installed into the same directory (based on a different AppID). There should be no need to go behind its back and rename the uninstaller files.



回答4:

Just dealt with this myself. You shouldn't move the uninstaller executable itself around, for reasons Martin Prikryl pointed out. But I agree it is unsatisfying to have a bunch of numbered uninstallers sitting in a directory with no obvious means of telling which is which.

There is a solution using the facilities Inno Setup provides. In the [Setup] section:

[Setup]
...
UninstallFilesDir=Uninstall\exe\{#NAME_OF_APP}
...

Then in the [Dirs] section:

[Dirs]
...
Name: Uninstall\exe; Attribs: hidden;
Name: Uninstall\exe\{#NAME_OF_APP}; Attribs: hidden;
...

And finally you create named shortcuts in [Icons] that point to the uninstallers which will always have the same name because you've sequestered them:

[Icons]
...
Name: Uninstall\{#NAME_OF_UNINSTALLER}; Filename: Uninstall\exe\{#NAME_OF_APP}\unins000.exe
...

This leaves references in the OS to the uninstallers alone, hides the confusing executable names in a folder the user won't usually see but can still access, and provides named, descriptive shortcuts that can all live in the same folder. You can also give the shortcuts a good icon. For good measure, maybe drop an extra README in the \exe directory to explain what is going on just in case someone gets nosey (they will, naturally).



回答5:

Well, while it's still not possibly to nativelly change the uninstaller name then I'll use Batch commands at the run section to rename the uninstaller and to do the same in the uninstaller registry paths:

[Run]
Filename: {cmd}; Parameters: "/C Move ""{app}\unins000.exe"" ""{app}\Uninstallers\{#ApplicationName} - uninstall.exe"""; StatusMsg: Installing {#ApplicationName}...; Flags: RunHidden WaitUntilTerminated
Filename: {cmd}; Parameters: "/C Move ""{app}\unins000.dat"" ""{app}\Uninstallers\{#ApplicationName} - uninstall.dat"""; StatusMsg: Installing {#ApplicationName}...; Flags: RunHidden WaitUntilTerminated

Filename: REG.exe; Parameters: "ADD ""HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Windows 8 ContextMenu - {#ApplicationName}_is1"" /V ""UninstallString"" /T ""REG_SZ"" /D ""\""{app}\Uninstallers\{#ApplicationName} - uninstall.exe\"""" /F"; StatusMsg: Installing {#ApplicationName}...; Flags: RunHidden WaitUntilTerminated
Filename: REG.exe; Parameters: "ADD ""HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Windows 8 ContextMenu - {#ApplicationName}_is1"" /V ""QuietUninstallString"" /T ""REG_SZ"" /D ""\""{app}\Uninstallers\{#ApplicationName} - uninstall.exe\"" /SILENT"" /F"; StatusMsg: Installing {#TipName}...; Flags: RunHidden WaitUntilTerminated


回答6:

Inno Setup does not offer any way to let you name (or rename) the uninstaller. Inno Setup takes care of naming conflicts on its own.

Also note that when you try to rename the uninstaller manually (like some answers here do), you break the reference to the uninstaller in Add or remote application in Control Panel.

Even if you fix the reference, there's another problem. When you upgrade later, the new installer won't find logs of the previous installer and won't be able to merge them. Consequently a future uninstallation won't completely remove the application. See the Appending to Existing Uninstall Logs in Inno Setup documentation.