T
tkondal
Hi,
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):
file=GetFilename();
bLock = IsThereAFileLockOnFile(file)
If (bLock)
{
process = GetLockingProcess(file);
TerminateProcess(process);
}
DeleteFile(file);
Thanks.
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):
file=GetFilename();
bLock = IsThereAFileLockOnFile(file)
If (bLock)
{
process = GetLockingProcess(file);
TerminateProcess(process);
}
DeleteFile(file);
Thanks.