Today I tried to copy files and folders off a USB hard disk (NTFS formatted) on my Windows 7 desktop. I encountered multiple files with permission problems. The manual method to change permissions is very tedious, so I created a script (DOS batch file) to do the same.
During the copy operation. I got this error to "provide administrator permission to copy this file." Not very helpful and initially very worrying!
First, find the offending file - you'll notice the path is not given so even finding the right culprit is a nightmare in itself.
Then, right click > Properties > Security. You'll see this message instead of the usual security info. Hit Continue. And select a user to assign ownership to - I chose Administrators.
A dialog box will confirm the ownership change but mention something to the effect that access rights are still not set. So hit Continue again, and this time you'll get this dialog:
You'll notice the access rights (full control, modify, read, etc.) are assigned to two unknown users that used to live on another computer. Anyway, hit Add:
I decided to add all Administrators - type in "Administrators" in the text box and hit ok. But you could add Everyone too I think.
And now if you look and the security properties, you'll get something like this. Make sure you allow "Full control".
Hit OK in all dialogs. And if your error message in the first screen shot above is still on-screen, just click Continue and if all's well, the file copy operation will resume where it got stuck.
That was a lot of clicks!
As always, be careful and validate. Run
icacls to check what I'm doing here for yourself!
Here's the alternative. Create a batch file, e.g.
if /i %1 equ "" goto :eof pushd cd "%1" takeown /R /F . icacls . /grant Administrators:(OI)(CI)F /T popd
cmd using Run as Administrator. Then run
fixaccess "X:\bad\folder" replacing the path as appropriate.
That should do it. And if your error message in the first screen shot above is still on-screen, just click Continue. xx