473,223 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,223 software developers and data experts.

copy locked files

Hello,

do you know of any way to copy locked / opened files under win xp?
I know there is something like "Volume Shadow Copy" but I don't know
how to use it.
Maybe someone already has a python solution?
Many thanks
Daniel

Jun 18 '07 #1
3 5769
Do you mean files marked in-use by the OS, like DLLs used by an open
application?

There shouldn't be anything preventing you from copying in-use files, or
even read-only files if that's what you meant:

import shutil
shutil.copy('C:\\my_application\\test.dll',
'C:\\new_folder\\test.dll')

Although you can't move or delete an in-use file, AFAIK.

- Adam

-----Original Message-----
From: py***************************************@python.o rg
[mailto:py***************************************@p ython.org]
On Behalf Of ru**********@web.de
Sent: Monday, June 18, 2007 9:50 AM
To: py*********@python.org
Subject: copy locked files

Hello,

do you know of any way to copy locked / opened files under win xp?
I know there is something like "Volume Shadow Copy" but I
don't know how to use it.
Maybe someone already has a python solution?
Many thanks
Daniel

--
http://mail.python.org/mailman/listinfo/python-list
Jun 18 '07 #2
Hi Adam,

On 18 Jun., 18:41, "Adam Pletcher" <a...@volition-inc.comwrote:
Do you mean files marked in-use by the OS, like DLLs used by an open
application?
I dont know the exact name, but some programs totally lock the files,
like Visual Studio

shutil.copy('C:\\a\\test\\test.ncb','C:\\b\test.nc b')

IOError: [Errno 13] Permission denied: 'C:\\a\\test\\test.ncb'

As soon as I quit the application I can copy the file.

(I am writing a backup software which saves the changed files every
few minutes. If there was a slight possibility
to copy a file which is written at the same moment and therefore not
consistent this is still better than no backup)
>
There shouldn't be anything preventing you from copying in-use files, or
even read-only files if that's what you meant:
That's exactly my opinion!

>
Although you can't move or delete an in-use file, AFAIK.
this seems to be easier, you can use inuse.exe
http://support.microsoft.com/kb/228930/en-us
Daniel

Jun 18 '07 #3


Adam Pletcher wrote:
Do you mean files marked in-use by the OS, like DLLs used by an open
application?

There shouldn't be anything preventing you from copying in-use files, or
even read-only files if that's what you meant:

import shutil
shutil.copy('C:\\my_application\\test.dll',
'C:\\new_folder\\test.dll')

Although you can't move or delete an in-use file, AFAIK.
I had to deal with a similar problem using the Win32 API in C recently. You can't move or delete an in-use file, as Adam noted. However, you *can* rename a file (see http://www.nntp.perl.org/group/perl....1/msg2437.html as a nice summation of the problem), and MoveFileEx() in the Win32 API has a flag that will delete a file on the next reboot.

As far as copying an in-use file, there are two possibilities I can think of. One would be to try disconnecting the lock using the openfiles command (this may not exist on all versions of Windows, but it is there on my WinXP box). The other would be to use Locked Files Wizard (used to be called CopyLock) http://noeld.com/programs.asp?cat=misc

It comes with a command line version of the tool that you can call from your Python script as necessary. Neither is an ideal solution but I can't find any other suggestions out there on dealing with this from Python.

HTH,

-Jay
Jun 18 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bishop | last post by:
For example the files in a computers windows directory and profile directory that the application is running on.
8
by: Chris Strobel | last post by:
I have 2 web servers where I need to write a PDF file and need to keep them in sync. In others words, If the Server1 is getting called to create the PDF, then it needs to copy the PDF to the other...
5
by: Verane | last post by:
Hi, I have read the thread named "Could not copy temporary files to the output directory" on this newsgroup. And I have the same symptoms on my machine. But I didn't find any solution suitable for...
11
by: MarkusR | last post by:
Good day, I need to safely copy files from one directory to another. I need to make sure that I do not lock the file making it unreadable by others. I am not sure if this is the default...
0
by: SP | last post by:
Dear all! I have written a web service which should archive files in a server directory. The files are placed in a directory that the web server can access. In the first step I copy them to a...
13
by: jim | last post by:
Is there a way (using VB.Net or C#) to copy open or locked files? Thanks! jim
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.