[python-win32] Calling random Windows function?

Roger Upole rwupole at msn.com
Sun Oct 25 21:59:41 CET 2009


Aahz wrote:
> On Fri, Oct 23, 2009, Tim Roberts wrote:
>> Aahz wrote:
>>>
>>> Perhaps it would be better to think more strategically.  I don't 
>>> actually
>>> care about the list of open files.  What I care about is a list of files
>>> that I want to process and checking whether any of them are open.  What
>>> would be the canonical way of doing that on Windows?  It doesn't matter
>>> whether it is in batch or file-by-file.
>>
>> Wouldn't the least-effort solution be simply to try to open each file,
>> and see if the open succeeds?
>
> We used to do that, but it was interfering with other programs.  (It's
> similar to backup, and we don't want to interfere with e.g. Excel, which
> previously was an issue if someone had an open spreadsheet and tried
> saving it while we were uploading it.)

Have you tried opening the files for exclusive access (ie no sharing) ?

> I suppose we could switch to using Volume Shadow Copy, I'm not sure why
> we didn't try that earlier.

If you decide to use Volume Shadow Copy, I've wrapped some of the
IVss* interfaces for Python, enough to be able to backup selected files
from a volume.  Bear in mind that if an application has a file open for
writing and is not VSS-aware, you may get the file in an inconsistent state.

       Roger



More information about the python-win32 mailing list