Copy a file that is being used by another process

  • Thread starter Thread starter Medicol
  • Start date Start date
  • Tags Tags
    File Process
Click For Summary

Discussion Overview

The discussion revolves around the challenges of deleting a file that is currently in use by another process on a computer. Participants explore various methods and considerations for addressing issues related to file access rights, particularly in Windows and Linux environments.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant reports an error message regarding insufficient access rights when attempting to delete a file that is in use by another process.
  • Another suggests using safe mode in Windows or a Linux LiveCD to delete the file, while cautioning about the potential risks of deleting critical system files.
  • Some participants propose that there are programs capable of deleting locked files without entering safe mode, expressing interest in how these programs operate.
  • It is noted that identifying the process locking the file is crucial, and one participant shares a method involving Process Explorer to find and stop the locking process before deletion.
  • There is a suggestion to rename the file as a potential workaround, although questions arise about whether renaming is possible when the file is locked.
  • Concerns are raised about the implications of deleting temporary or system files, with warnings about potential catastrophic consequences.
  • One participant mentions using a DOS command to force a delete, emphasizing the importance of understanding the file's purpose before proceeding.
  • Another participant shares a personal blog link discussing undeletable files, although they clarify that it may not apply if the file is in use.
  • A command prompt method is suggested for attempting to delete the file, specifically using the 'del' command with specific attributes.

Areas of Agreement / Disagreement

Participants express a range of views on how to handle the situation, with no consensus on the best approach. There are multiple competing suggestions and methods discussed, reflecting uncertainty about the most effective solution.

Contextual Notes

Participants highlight the importance of understanding the implications of deleting certain files, particularly system-critical files, and the potential risks involved in various methods proposed.

Who May Find This Useful

This discussion may be useful for users experiencing issues with locked files on their computers, particularly those seeking various methods to delete or manage such files in Windows or Linux environments.

Medicol
Messages
226
Reaction score
54
I have a file in my computer that I would want to delete but I always get error message of insufficient access right even though I am already an administrator. The file is being used by another process I don't know. That process seems to gag on the file forever. I scan the system but no virus is recognized.

In order to delete this file, what should I do ?
 
Computer science news on Phys.org
Can you bring up your computer in some sort of safe mode? Windows has this feature.

For linux you might use Knoppix to boot and then mount the drive of interest and find the file to delete.

However, before you delete do you know what its used for? What is its name?

Have you searched online to see if others have had problems with this same file to see what they did?

Just being cautious, I remember a scam one time was to have users delete some critical windows system file and replace it with a malware version.
 
I am sure there are programs that can still do this without having to enter safe mode. I'd like to know how they can do that.
 
Might be a much better idea to simply rename it first. Then whatever is trying to use it won't be able to, but if it's a system-critical file, you can restore it
 
DaveC426913 said:
Might be a much better idea to simply rename it first. Then whatever is trying to use it won't be able to, but if it's a system-critical file, you can restore it
Can you even rename a file if its in use? (or locked, for that matter)

To the OP: perhaps you can name the file you are trying to delete.
 
StevieTNZ said:
Can you even rename a file if its in use? (or locked, for that matter)
I am riffing off jedishr's suggestion that might allow it.
 
It's not clear what file you are trying to delete. Windows uses a lot of scratch or temporary (and some not so temporary) files while it is active, so you want to make sure you are not trying to delete one of these files. Doing so can mess you up, sometimes catastrophically.
 
  • Like
Likes   Reactions: FactChecker
Why do you want to delete it and what do you know about that file? If you are sure you know why the file is there and still want to delete it, you may be able to force a delete with a DOS command. They often work when the Windows delete fails. Be sure you know what you're doing first. Rename probably won't work if Windows thinks the file is in use, but you can copy it to a different name and then try delete the original. If everything still works, then delete the copy. If things stop working, rename the copy to the original name.
 
Last edited:
  • #10
When a file is in use, the file is locked by the process that's using it. You cannot rename/delete or do anything to modify that file other than through the process that has it locked. Generally, this means you cannot delete the file till the process releases the resource or the process itself stops.

There's two ways that come to my mind to delete the file.
1) Identify the host process that has this file locked, stop the process and then delete the file.
or
2) reboot the system into safemode (or into another OS like a Linux LiveCD) and delete the file from there.
safemode delete will work if the file we want to delete is a 3rd party app/data file. If it's a system executable or DLL you're likely to run into the same problem.

So, for the first way. Identifying the host process locking a resource. I will use the example of deleting an executable while it's running.
First, you'll need to download Process Explorer from the sysinternals website. (http://technet.microsoft.com/en-ca/sysinternals/bb896653.aspx)
Here's the example of me trying to delete the process explorer executable while it's running
1.jpeg


Now we have to find out which process is locking this executable.
So we click find and, type in the full name of the executable including the extension and search.
2.jpeg

As you can see, we have 2 processes that are associated with this file. Explorer.exe is listed because it's the GUI and i double clicked the file to run it. So it shows up as it's running under Explorer.exe. This is not the process that's locking the executable. Its the other one, PID (Process ID) 4804. that's what we need to stop

So we sort by PID and find 4804. Right click on the process and Kill Process. Once it's closed, we can delete the file.
3.jpeg


Now, you have to make sure that the file you are deleting is not system critical and the process that's locking it is not system critical. Google is your friend.
Hopefully this helps you out.

Cheers!
 
  • Like
Likes   Reactions: Medicol and jim mcnamara
  • #11
  • Like
Likes   Reactions: Medicol
  • #12
Medicol said:
I have a file in my computer that I would want to delete but I always get error message of insufficient access right even though I am already an administrator. The file is being used by another process I don't know. That process seems to gag on the file forever. I scan the system but no virus is recognized.

In order to delete this file, what should I do ?

I am not sure if it is a similar problem or not, but I had an undeletable file which I blogged about here: http://harborsparrow.blogspot.com/2012/09/undeletable-files-on-ntfs-file-system.html

If the file is in use by another process, my blog will not help. But if insufficient permissions are the problem, the blog I made might help.
 
  • Like
Likes   Reactions: Routaran
  • #13
In the Windows command prompt try

Code:
cd <file_path>
del <file_name> /a:s
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 60 ·
3
Replies
60
Views
8K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 14 ·
Replies
14
Views
7K
  • · Replies 30 ·
2
Replies
30
Views
3K