如何在删除文件后延迟继续卸载?

发布于 2024-11-01 03:06:44 字数 286 浏览 1 评论 0原文

我的卸载脚本退出正在运行的应用程序,但它并未完全消失(由于计时问题),因此以下 UninstallDelete 部分不会删除 {app} 文件夹,因为它不为空。如果我手动退出应用程序,然后运行卸载脚本,那么 {app} 文件夹就会被正常删除。

[卸载删除] 名称:{应用};类型:drifempty

我想知道是否有人有任何建议来延迟删除 {app} 文件夹的尝试。我想过使用 Inno Setup 的内置程序 Sleep,但我不知道如何以及在哪里使用它(例如无法从 [UninstallRun] 部分调用它。还有其他建议吗?

My Uninstall script exits the running app however it is not completely gone (due to timing issue) and therefore the following UninstallDelete section does not delete the {app} folder since it is not empty. If I exit the app manually and then run the uninstall script then the {app} folder gets deleted fine.

[UninstallDelete]
Name: {app}; Type: dirifempty

I was wondering if anyone has any suggestions to delay the attempt the remove the {app} folder. I thought of using the Inno Setup's built-in procedure called Sleep but I could not figure out how and where to use it (e.g. couldn't call it from [UninstallRun] section. Any other suggestions?

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

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

发布评论

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

评论(1

2024-11-08 03:06:44

您可以挂接function InitializeUninstall(): Boolean;procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);函数。

它在卸载开始之前运行,您可以在此处进行检查以确保应用程序未运行。使用FindWindowByClassNameFindWindowByWindowsName

如果您发现它正在运行,您可以提示用户关闭该应用程序。
当用户说它已关闭时,您可以调用 Sleep() 给它足够的时间关闭,然后再次检查以确保应用程序确实关闭。

如果您的应用程序在运行时创建 Mutex,您可以使用 CheckFormMutexes
作为 FindWindowXXX 调用的替代方法。

这个问题解决了另一个选项:Inno Setup 检查正在运行的进程

无论哪种检测方法,调用Sleep来等待都会解决这个问题。

You could hook the function InitializeUninstall(): Boolean; or procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); function.

This runs before uninstall starts, you can place a check here to make sure the application is not running. Using FindWindowByClassName or FindWindowByWindowsName

If you find it running you could prompt the user to close the application.
When the user says's it's closed you could then call Sleep() to give it enough time to close, before checking again to make sure the application is really closed.

If your application creates a Mutex when it's running, you could use CheckFormMutexes
as an alternative to the FindWindowXXX calls.

Another option is addressed in this question: Inno Setup Checking for running process

Regardless of the detection method calling Sleep to wait would resolve this problem.

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