简体   繁体   English

如何在 Inno Setup 中获取卸载程序名称

[英]How to get the uninstaller name in Inno Setup

I have a project with different variants , which all install to the same location eg C:\\ABC\\ .我有一个具有不同变体的项目,它们都安装到相同的位置,例如C:\\ABC\\ Here the uninstallers are named unins000, unins001.. and so on.这里的卸载程序被命名为 unins000、unins001.. 等等。 I have searched on net to changed the uninstaller names, and there is no inherent way to change the uninstaller name.我在网上搜索过以更改卸载程序名称,并且没有更改卸载程序名称的固有方法。

I have a workaround , by which I use the [Run] section to rename unins000.exe to the name of my choice.我有一个解决方法,通过它我使用[Run]部分将unins000.exe重命名为我选择的名称。 This works great on project folders when there will be only one uninstaller.当只有一个卸载程序时,这对项目文件夹非常有效。 However, in my case, the uninstaller name is not known to me.但是,就我而言,我不知道卸载程序名称。

Can someone suggest me a way to get the uninstaller name ?有人可以建议我获取卸载程序名称的方法吗? I will put the name accordingly in my code.我将相应地将名称放在我的代码中。

Please don't suggest me to look for timestamp.请不要建议我寻找时间戳。 That will not be an acceptable solution.这将不是一个可接受的解决方案。

Thanks in advance.提前致谢。

Inno Setup does not offer any way to let you name (or rename) the uninstaller. Inno Setup 不提供任何方式让您命名(或重命名)卸载程序。

Also note that when you rename the uninstaller manually (like you are doing), you break the reference to the uninstaller in the Add or remote application in Control Panel.另请注意,当您手动重命名卸载程序时(就像您正在做的那样),您会在控制面板的添加或远程应用程序中中断对卸载程序的引用。 Do not do that.不要那样做。

Another problem is that 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.请参阅 Inno Setup 文档中的附加到现有卸载日志

The user should not uninstall the application by going to installation folder and executing the uninstaller.用户不应通过转到安装文件夹并执行卸载程序来卸载应用程序。 The user should go to Control Panel and select the application by its name.用户应转到控制面板并按名称选择应用程序。


Anyway, the uninstallers are numbered sequentially, so you can pick the uninstaller with the highest number.无论如何,卸载程序按顺序编号,因此您可以选择编号最高的卸载程序。

I added the code below I used to achieve I wanted.我在下面添加了我用来实现我想要的代码。 Basically, what I am doing now is I create a seperate folder for each variant, where I store the individual uninstaller ( as I was not able to get the uninstaller which I will need to rename ) .基本上,我现在所做的是为每个变体创建一个单独的文件夹,在其中存储单个卸载程序(因为我无法获得需要重命名的卸载程序)。

The project structure is now项目结构现在是

C:\\ABC\\Uninst\\<Variant-1>\\<variant1-uninstaller> C:\\ABC\\Uninst\\<Variant-2>\\<variant2-uninstaller> C:\\ABC\\Uninst\\<Variant-1>\\<variant1-uninstaller> C:\\ABC\\Uninst\\<Variant-2>\\<variant2-uninstaller>

Add the [Run] section , this will change the uninstaller name to whatever is required.添加[Run]部分,这会将卸载程序名称更改为所需的任何名称。 Also, registry entry in HKLM will be modified so that shortcuts and Control panel can uninstall the programs without any issues.此外,HKLM 中的注册表项将被修改,以便快捷方式和控制面板可以毫无问题地卸载程序。

 `[Run]

  ;First rename the uninstaller files, then modify in registry
  ; /C : run CMD, execute command, then close the CMD.exe
  Filename: {cmd}; Parameters: "/C ren ""{app}\Uninst\unins000.exe"" ""Uninstall_{#ApplicationName}.exe"""; Flags: RunHidden WaitUntilTerminated

 Filename: {cmd}; Parameters: "/C ren ""{app}\Uninst\unins000.dat"" ""Uninstall_{#ApplicationName}.dat"""; Flags:  RunHidden WaitUntilTerminated

 ; REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f]
 ; /F : Force overwrite
 Filename: REG; Parameters: "ADD ""HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{#AppNameInReg}_is1"" /V ""UninstallString"" /T ""REG_SZ"" /D ""\""{app}\Uninst\Uninstall_{#ApplicationName}.exe"""" /F"; StatusMsg: Flags: RunHidden WaitUntilTerminated

 Filename: REG; Parameters: "ADD ""HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{#AppNameInReg}_is1"" /V ""QuietUninstallString"" /T ""REG_SZ"" /D ""\""{app}\Uninst\Uninstall_{#ApplicationName}.exe /SILENT"""" /F"; Flags: RunHidden WaitUntilTerminated

Add the following line in [Setup] section UninstallFilesDir={app}\\Uninst\\ This will create unins000.exe in Uninst folder.[Setup]部分添加以下行UninstallFilesDir={app}\\Uninst\\这将在Uninst文件夹中创建unins000.exe

Please note that I have solved my issue.请注意,我已经解决了我的问题。 I posted my code for any one who want to do similiar things.我为任何想做类似事情的人发布了我的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM