Home » Questions » Computers [ Ask a new question ]

What is the command to remove an in use file in cmd.exe?

What is the command to remove an in use file in cmd.exe?

I am trying to remove an in use file using command prompt. I am not successful so far. I have used the del command but in vain.

Asked by: Guest | Views: 83
Total answers/comments: 4
Guest [Entry]

"In general, there is no command for that, you have to close the program using the file, or at least force it to close its link to it.

You can find more details on this question : How do I delete a 'locked' file?

Be careful though about using Unlocker, closing handles is not a safe operation, it can lead to loss of data, or invalid state in a program (more details here). You have to be sure that you know the program using the file, and that you can safely close it, or force it to release the file."
Guest [Entry]

You cannot delete a file from cmd that is in use. Try re-booting and deleting right after the boot, when some services aren't running. Otherwise, look for the process that is using the file and kill it and then the file, or find online software to delete a file that is in use.
Guest [Entry]

If application can't be deleted because it is in use by your system, You could try locating file (if you know the location of the file, if not find it via Task manager/processes bar) and "cd" via cmd to its folder. Then try "TASKKILL /f /pid "appname" & del /f "appname"", this will kill the running process and try to immidiately delete the executable. If it doesn't work, try a couple of times so it doesn't have time to restart the process and can be permanently removed in that time frame.
Guest [Entry]

"You can use handle.exe by SysInternals:
handle.exe /accepteula -p PROCESS_PID -c HANDLE_NUMBER -y

Run handle.exe -? to learn more."