Possible duplicate:
DirectoryInfo.Delete (True) Does not delete when the folder structure is open in Windows Explorer
People, I write a python test harness, and part of the project involves removing the application, and then reinstalling it every night. Part of the deletion task involves deleting the data catalog. During the day, testers / developer will be registered in the computer, and sometimes from the command line and / or log file remains open. This causes my script to crash because windows will not allow me to delete the file if another process has a handle.
I would like to know if it is possible to get the pid of a process that is holding onto a file so that I can kill the process using WMI or something like that? I would like to do this without unloading people.
If this is not possible, is there a way from python to force all users to log out to get a system in which my script can continue to work without waiting until I show and kill users of the process / logout?
Any suggestions are generally welcome. I am not an experienced Windows programmer.
source
share