1
I have a database service running in a known directory C:\meuBanco\exe\
and now I have developed an updater of this service, which performs the following steps:
- For service
- Excludes the folder
exe
:rd /s /q %DIRSERV%\exe\
- Unzip the zip with the new service in the folder
exe
The problem is in step 2, where eventually it is not possible to delete the folder as it is in use.
But when the update runs, it can delete the folder as it should not have any process blocking the folder exe
.
So I ask: there is a way to force the removal of a directory in Windows even if it is in use?
I believe you need to elevate privileges to the level of the system, after all, this feature is for security, for no one to erase something that is in use and compromise another application that is making this use.
– user28595
@diegofm I already run the update as administrator. There is another level possible?
– Murillo Goulart
Yes, there are other system levels above the administrator, so much so that there are folders and files that you, even as admin, can’t access in windows
– user28595
Try this: http://stackoverflow.com/a/98069/5524514
– user28595
Terminating executables or files that are open in the directory does not resolve? to end with the
takkill
example:taskkill /f /im notepad.exe
then delete the directory...– Laércio Lopes
@diegofm The workaround with Robocopy worked!! Awesome. If you want to answer..
– Murillo Goulart
@Laérciolopes I don’t know what the executables are (they might be external applications), so I would have to first figure this out.
– Murillo Goulart