Access denied when renaming a folder

I don’t know if it’s right to ask this question, but I’ll ask him anyway.

I have a common problem when trying to rename one of my folders; he says access is denied. I have full administrator rights on my computer. The problem only occurs when I try to do this using the command line or batch files. I can manually rename the folder without any problems. But I need to rename it with the ren command. This is an annoying problem, and I heard other people have the same problems. Usually they fix this by re-taking ownership of the folder and restarting the computer. It works for me, but I hate doing it every time. Is there a permanent solution that I can make to stop this problem? Also, when this problem occurs, it happens with all folders; I cannot rename them using the ren command.

thanks

+5
source share
2 answers

The answer is pretty simple:

Windows does not allow the removal or renaming of a directory / folder that

  • the current directory of any running process (application / service), such as a team process, or
  • any subdirectory of the directory to rename is the current directory of the running any process, or
  • any file is opened in the directory for renaming or any of its subdirectories by any process using OF_SHARE_DENY_READ, OF_SHARE_DENY_WRITE, OF_SHARE_EXCLUSIVE used when opening the file.

In other words, if the directory itself or any file or subdirectory in this directory or its subdirectories is used by any application, Windows will refuse to rename or delete the directory.

On Unix / Linux, you can delete or rename a directory while it is using 1 or more running processes. The running * nix process must handle a special use case when a directory or file that just managed to access a millisecond does not suddenly exist before that.

+5
source

Well, before you can run this command, you must have permission to do so, since overwriting or modifying files from the command line requires administrator rights. Once you do this, enter the following:

 ren (path name) (modified name, no quotation marks) 
+1
source

Source: https://habr.com/ru/post/1261992/


All Articles