如何在删除文件后延迟继续卸载?
我的卸载脚本退出正在运行的应用程序,但它并未完全消失(由于计时问题),因此以下 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以挂接
function InitializeUninstall(): Boolean;
或procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
函数。它在卸载开始之前运行,您可以在此处进行检查以确保应用程序未运行。使用
FindWindowByClassName
或FindWindowByWindowsName
如果您发现它正在运行,您可以提示用户关闭该应用程序。
当用户说它已关闭时,您可以调用
Sleep()
给它足够的时间关闭,然后再次检查以确保应用程序确实关闭。如果您的应用程序在运行时创建
Mutex
,您可以使用CheckFormMutexes
作为
FindWindowXXX
调用的替代方法。这个问题解决了另一个选项:Inno Setup 检查正在运行的进程
无论哪种检测方法,调用
Sleep
来等待都会解决这个问题。You could hook the
function InitializeUninstall(): Boolean;
orprocedure 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
orFindWindowByWindowsName
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 useCheckFormMutexes
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.