I delete a windows service with a sc.exe delete <serviceName>
.
Immediately after that, I delete the files owned by the service (an exe and a couple of dlls) and I cannot because these files are still locked.
I've found out that it works if I execute a sleep of 3 seconds (I wonder what is Windows doing for 3 seconds!) between the service delete and the files delete.
Is there some more elegant and secure solution?
Probably useless detail: I'm running this from Inno Setup
on Jenkins
on Windows 7