Deleting files and folders used by other processes on Windows

tkondal at tkondal at
Tue Jul 17 20:21:21 CEST 2007


I have been looking into making my file cleaning script more
intelligent.  The goal of the script is to delete everything on a
drive except for a couple of folders which are skipped by the script.
Recently, I noticed that some files where not being deleted because a
process was using them.  Is there a recipe (needs to run on Windows XP/
2003) for doing the following (more specifically, I need a way to
determine which process is holding a lock on my file):

bLock = IsThereAFileLockOnFile(file)
If (bLock)
 process = GetLockingProcess(file);


More information about the Python-list mailing list