Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
Thanks for the edits. Damn iPad autocorrect :) –  MDMarra Jul 1 '12 at 15:59
    
Thanks for the tip about Handle! It helped me solve the problem. I've documented my steps in my own answer. –  Iain Elder Jul 1 '12 at 16:06
add comment
up vote 1 down vote accepted

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 the SourceControl directory:

handle SourceControl

The output shows that TSVNCache.exe has an open file handle in the directory:

TSVNCache.exe      pid: 2860   type: File           1C8: C:\SourceControl\Project

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:

Set 'Status cache' to None to terminate the TSVNCache.exe process.

Repeat the handle search. The output of handle SourceControl confirms that there are no more open file handles in the directory:

No matching handles found.

Move the directory

Repeat the command to move the directory. The operation succeeds with the expected output:

1 file(s) moved.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.