开发者

How to delay continuation of Uninstall after it deletes files?

开发者 https://www.devze.com 2023-02-25 13:50 出处:网络
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 e

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 fi开发者_C百科ne.

[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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号