如何使用 Inno Setup 撤销先前安装计划的文件删除

发布于 2024-08-17 21:11:20 字数 331 浏览 4 评论 0原文

我已经用 Inno Setup 发布了一个应用程序。遗憾的是,该应用程序安装了一个数据库文件作为源文件,因此如果卸载该应用程序,则整个数据库文件将被删除。

我很快就会发布新版本。我希望新版本覆盖以前的版本,根本不安装数据库文件,而是由应用程序本身创建数据库。

如果我安装新版本而不安装原始版本,则一切正常。该应用程序创建一个数据库文件,卸载后,该数据库保留在计算机上。

问题是,如果我在计算机上安装了以前的版本,然后安装了新版本,那么在卸载新版本后,DB 文件总是会被删除。

两个应用程序都使用相同的 AppId 进入相同的目录。

如何撤销先前安装程序安排的文件删除?

I have release an application with Inno Setup. Sadly this application had installed a DB file as a source file, so if the application is uninstalled then entire DB file is removed.

I'm going to release a new version soon. I would like the new version to override previous one, not install DB file at all and instead create the DB by the application itself.

If I install the new version without ever installing the original one, everything works fine. The application creates a DB file and after uninstalling, the DB stays on the machine.

The problem is that if I had installed the previous version on the machine and then installed a new version, then after uninstalling the new version the DB file is always removed.

Both application go to the same directory with the same AppId.

How can I revoke a file removal scheduled by the previous installer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

玩世 2024-08-24 21:11:20

如果添加 uninsneveruninstall 标志,您可以继续安装数据库文件。卸载应用程序时,这将保留文件和目录。不幸的是,现在添加此标志不会有帮助,因为卸载仍然会删除数据库文件 - 初始安装中数据库文件的文件条目不会被以后的安装修改,因此数据库文件将始终被删除。似乎没有办法解决这个问题。

您可以做的是将代码添加到新的安装程序(或卸载程序)中,以创建数据库文件的备份副本。然后,文件和目录将被保留,因为卸载程序默认不会删除安装程序尚未创建的任何内容。

You can keep installing a database file if you add the uninsneveruninstall flag. This would leave the file and the directory when the application is uninstalled. Unfortunately adding this flag now won't help, as the uninstall will still remove the database file - the file entry for the database file from the initial installation isn't modified by later installations, so the database file will always be removed. There seems to be no way around this.

What you can do is adding code to your new installer (or uninstaller) that makes a backup copy of the database file. The file and the directory will then be preserved, as the uninstaller does per default not delete anything that the installer hasn't created.

等待我真够勒 2024-08-24 21:11:20

在新版本中,我建议您使用不同的名称创建DB文件。这是确保它永远不会被任何以前的安装程序卸载的简单方法。

新版本的安装程序(使用某些 Pascal 脚本)或应用程序本身可以检测具有旧名称的数据库(如果存在),并且:

  • 将数据从旧文件复制到新文件
    • 也许可以将旧的重命名为具有不同名称的备份
  • ,或者可能只是将文件重命名为新名称

您必须小心考虑所有可能的安装、卸载、重新安装方案,不要弄乱数据在每个场景中。

In the new version, I suggest you create the DB file with a different name. That would be a simple way to ensure that it would never be uninstalled by any previous installer.

Your installer for the new version (using some Pascal script), or perhaps the application itself, could detect the DB with the old name, if it exists, and:

  • copy the data from the old to the new file
    • perhaps rename the old one as a backup with a different name
  • or perhaps just rename the file to the new name

You would have to be careful to consider all the possible install, uninstall, reinstall scenarios and not to mess up the data in each scenario.

柠檬 2024-08-24 21:11:20

感谢您的回复。我同意这里最明显的解决方案是将数据库文件复制到新位置并忘记该问题。所以我投票给 mghie。

我设法通过删除 unins000.* 文件来实现我所需要的:

[InstallDelete]
Type: files; Name: "{app}\unins000.dat"
Type: files; Name: "{app}\unins000.exe"

我需要删除这两个文件。此外,我必须重新安装带有“ignoreversion”标志的所有文件,以便新的卸载程序删除它们:

[Files]
Source: {#SourceFileDir}\my.exe; DestDir: {app}; Flags: ignoreversion

这当然有一些缺点,并且不是 100% 安全,但在我的情况下有效。

Thank you for your responses. I agree that the most obvious solution here is to copy the DB file to a new location and forget about the problem. So my upvote goes to mghie.

I managed to achieve what I needed by removing unins000.* files though:

[InstallDelete]
Type: files; Name: "{app}\unins000.dat"
Type: files; Name: "{app}\unins000.exe"

I needed to remove both files. Additionally I had to reinstall all files with "ignoreversion" flag, so that they are to be removed by the new uninstaller:

[Files]
Source: {#SourceFileDir}\my.exe; DestDir: {app}; Flags: ignoreversion

This has some drawbacks of course and is not 100% safe, but works in my case.

黯淡〆 2024-08-24 21:11:20

尝试更改脚本中的 AppID。

来自 InnoSetup 帮助文件:

AppId 的值存储在卸载日志文件 (unins???.dat) 中,并由后续安装检查以确定它是否可以附加到特定的现有卸载日志。仅当现有卸载日志的 AppId 与当前安装的 AppId 相同时,安装程​​序才会追加到卸载日志。

Try changing your AppID in your script.

From the InnoSetup help file:

The value of AppId is stored inside uninstall log files (unins???.dat), and is checked by subsequent installations to determine whether it may append to a particular existing uninstall log. Setup will only append to an uninstall log if the AppId of the existing uninstall log is the same as the current installation's AppId.

凉月流沐 2024-08-24 21:11:20

这是一个相当高级的话题(我认为)。

我建议在 innosetup 的新闻组中提出这个问题:

news://news.jrsoftware.org/jrsoftware.innosetup

如果您在新闻组中收到答案,请在此处发布结果。

This is rather an advanced topic (I think).

I would suggest asking this question in the news group of innosetup:

news://news.jrsoftware.org/jrsoftware.innosetup

Please, if you receive an answer in the news group, post the result here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文