Copy a file that is being used by another process

In summary: Know the name of the file you're trying to delete 2) Be careful not to delete something else that's important 3) Be careful not to make things worse In summary, the file in question is being used by another process and Windows errors out when you try to delete it. You may be able to rename the file to make it inaccessible to the other process, but this is not guaranteed to work. You can try deleting the file with Windows's delete command, but this is not always successful. You can also try deleting the file from safe mode.
  • #1
Medicol
223
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
  • #2
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.
 
  • #3
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.
 
  • #5
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
 
  • #6
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.
 
  • #7
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.
 
  • #8
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 FactChecker
  • #9
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 Medicol and jim mcnamara
  • #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 Routaran
  • #13
In the Windows command prompt try

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

1. Why am I unable to copy a file that is being used by another process?

When a file is being used by another process, it means that the file is currently being accessed or modified by another program. This prevents any other programs from accessing or modifying the file, including the process of copying it.

2. Is there a way to copy a file that is being used by another process?

Yes, there are ways to copy a file that is being used by another process. One way is to close the process that is currently using the file. This will release the file and allow it to be copied. Another way is to use a specialized file copying software that can bypass the restrictions of a file being used by another process.

3. Can I copy a file while it is being used by another process without causing any issues?

It is not recommended to copy a file while it is being used by another process. This can cause unexpected issues such as corrupted files or data loss. It is best to wait for the file to be released by the other process before attempting to copy it.

4. How can I find out which process is currently using a file?

You can use the Task Manager (for Windows) or the Activity Monitor (for Mac) to view a list of running processes and identify which one is using the file. Alternatively, you can use specialized software designed to detect and manage processes.

5. Can a file be used by more than one process at the same time?

Yes, it is possible for a file to be used by more than one process at the same time. This is known as file sharing and is commonly used in situations where multiple users need to access the same file simultaneously. However, if a file is being modified by one process, it may prevent other processes from accessing or modifying the file until the first process is finished.

Similar threads

Replies
14
Views
2K
  • Computing and Technology
Replies
8
Views
3K
  • Computing and Technology
Replies
4
Views
1K
  • Computing and Technology
Replies
12
Views
2K
  • Computing and Technology
Replies
2
Views
2K
  • Computing and Technology
2
Replies
60
Views
7K
  • Computing and Technology
Replies
30
Views
1K
  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
9
Views
806
  • Computing and Technology
Replies
14
Views
2K
Back
Top