Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Need to clear the contents of a log file(s) which is(are) locked by a process already from command prompt. When I tried doing

echo "" > filename

I get a error saying, the file is locked by a process.

I couldn't even open the file in notepad, clear contents and save.

Currently I'm opening the file in notepad++ and quickly pressing CTRL + a,CTRL+x,CTRL+s :)

Is there a way to get this done from cmd? How is notepad++ able to handle edit and save while notepad is not able to?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You could use a program like Unlocker to release the lock: http://www.emptyloop.com/unlocker/

share|improve this answer

Locked files cannot be deleted, but they can be renamed. It could be that Notepad++ is using "safe saves" – creating a temporary file with the new contents, then quickly deleting the original (this step probably fails) and renaming temporary file to the original name.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.