In the root of my drive there exists a folder called SourceControl
that contains all the working copies of all my programming projects.
I would like to move the folder to my user directory (\Users\Me
), but something about the permissions on the folder forbids me. I don't remember how I created the folder.
When I execute the move command:
MOVE \SourceControl \Users\Me
I receive the following error:
Access is denied.
I have resolved a similar problem in the past using the Takeown
utility to assign ownership of the file to me, so I tried this command next:
TAKEOWN /F \SourceControl
It returns the following error:
ERROR: The current logged on user does not have ownership privileges
on the file (or folder) "C:\SourceControl".
I've just learned about the Icacls
utility, which can inspect and modify file permissions.
I used this command to inspect the permissions on the folder:
ICACLS \SourceControl
It produced this list:
\SourceControl BUILTIN\Administrators:(I)(F)
BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
NT AUTHORITY\SYSTEM:(I)(F)
NT AUTHORITY\SYSTEM:(I)(OI)(CI)(IO)(F)
BUILTIN\Users:(I)(OI)(CI)(RX)
NT AUTHORITY\Authenticated Users:(I)(M)
NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(IO)(M)
I think this means that normal user accounts, like mine, have permission only to read and execute (RX
) here, while administrator accounts have full control (F
).
I used Icacls to confer full control of the directory to my user account with this command:
ICACLS \SourceControl /grant:r Me:F
The command produces this output:
processed file: \SourceControl
Successfully processed 1 files; Failed processing 0 files
Now inspection of the permissions produces this output:
\SourceControl Domain\Me:(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
NT AUTHORITY\SYSTEM:(I)(F)
NT AUTHORITY\SYSTEM:(I)(OI)(CI)(IO)(F)
BUILTIN\Users:(I)(OI)(CI)(RX)
NT AUTHORITY\Authenticated Users:(I)(M)
NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(IO)(M)
But after this the move command still fails with the same error.
Is it possible to move this folder without invoking administrator rights? If not, how should I do it as administrator?
Sounds like you probably have open file handles to stuff in there. Kill any of your programs that might be using it. Reboot in safe mode if you have to.
If you're still having problems, there's a sysinternals tool called handles that can help you as well.
The error messages are misleading. The real problem was not insufficient permissions, but an open file handle on an object in the directory.
Mark Russinovich's Handle utility, suggested by MDMarra, helped solve the cause of the error messages.
Diagnose the error using Handle
Download Handle from the sysinternals website and extract handle.exe to
%WINDIR%
to put it on the path. Handle requires administrator rights, so open a new command prompt as Administrator. Run the following command to search for open file handles on objects in theSourceControl
directory:The output shows that TSVNCache.exe has an open file handle in the directory:
Close the file handle by terminating the process
TSVNCache.exe is a component of TortoiseSVN, a graphical SVN client, and a well-known resource hog.
To terminate the TSVNCache.exe process, disable TortoiseSVN's status cache in the TortoiseSVN Settings dialog:
Repeat the handle search. The output of
handle SourceControl
confirms that there are no more open file handles in the directory:Move the directory
Repeat the command to move the directory. The operation succeeds with the expected output: