I'm trying to make a installer, which will uninstall the older installation before installing the new installation.
The problem I am facing is that, that the uninstaller stops and then removes the installed service, after removing service, windows takes 15 sec to remove that service, waituntilterminated
flag doesn't help,
Because remove service command (I.e. service.exe remove
) finishes in under 1 sec
All I want is to add a 15 sec Sleep which will execute after all the processes under [UninstallRun]
finishes, or before the actual extraction of file takes place
Because, otherwise uninstaller fails to delete all the files, as the process is still running for 15 sec
Due to which, Reinstallation, throws an error that, Delete File fails Access Denied,
If I wait for 15 sec and then click on retry, then the installer is able overwrite old files
The most trivial solution is to make the sleep part of your uninstall command. You can use the timeout
command.
[UninstallRun]
Filename: cmd; Parameters: "/c service.exe remove && timeout /t 15 /nobreak"; \
Flags: runhidden
Better might be to instead execute the service.exe remove
from Pascal Script, from the CurUninstallStepChanged(usPostUninstall)
event. Then you can use the Sleep
function.
Though even better would be to check when the service really finishes, instead of waiting an arbitrary amount of time.
See for example How to uninstall the program when it is running and only after the user's confirmation to close and uninstall it - Inno Setup.