Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Work around emptying or writing to locked file.

0 views
Skip to first unread message

Kim

unread,
Aug 17, 2004, 2:04:54 PM8/17/04
to
The file is locked by a process that I cannot end ( it would mean
terminating an application that needs to be continually up )


I came across this solution to emptying a locked file ( console.log )
when i was writing a batch file for rotating logs in Windows 2000.

Attempting to write to the file with the echo command gave me:

The process cannot access the file because it is being used by another
process.

Attempting to delete the file using explorer gave me:

Error Deleting File or Folder
Cannot Delete: <file> there has been a sharing violation.
The source or destination file may be in use.

Anyhow you can get round this by copying one file over the other like
this:

copy clear.txt console.log

Windows will allow you to do that.

Pavel Srubar

unread,
Sep 3, 2004, 1:23:49 PM9/3/04
to
kimme...@yahoo.co.uk (Kim) wrote

> Attempting to write to the file with the echo command gave me:
> The process cannot access the file because it is being used by another
> process.

> I came across this solution to emptying a locked file ( console.log )

> copy clear.txt console.log

I prefer another solution:
IF EXIST console.bak DEL console.bak
REN console.log *.bak

Deleting locked files with FORCEDEL.EXE is discussed at
http://www.codeguru.com/Cpp/W-P/files/fileio/article.php/c1287/

Bye,
v
Sr.

0 new messages