Yesterday I helped my father to install his new computer with Windows 7. For several reasons I shall not mention, it was in the best interest to take the hard drive of the old (broken) computer and copy all the data from it to the new. What he (and me) wanted was to keep all the settings and other stuff and just reinstall his programs. That meant copying the entire AppData folder under his user account in addition to his normal files.
During this process obviously all files had kept the old SIDs, and as they weren't matching his new SID (on the new computer) I was having problems accessing the files. Lots of stuff didn't work. I was getting "No access" messages left and right when I tried to change the permissions of those copied files. That is when it dawned on me that even though his user account was registered as an administrator, it wasn't able to change the permission bits on those files.
To avoid having to mess around forever to reset permissions to default inherited ACL on all those files (around 30000 or so of them) I dug a bit around on the Internet and found out that there is a command in Windows 7 called icacls.exe that works very much in the same way as chmod on Linux, just that it supports NTFS ACLs.
After reading around I found a forum post that mentioned it, and was redirected to Microsoft's knowledge base article on icacls.exe. After looking over that one I found this command line that solved everything.
cd C:\Users\username icacls * /reset /T
/T switch makes it run recursively.
/reset, as the KB article explains, replaces the ACL on each file and folder with the default inherited ACL that just uses the ACL on the parent folder.
The last thing that was required was to run this command inside a cmd.exe shell with elevated privileges. You can do that by finding the Command Prompt icon in your start menu and right-clicking "Run as administrator".
Be aware that mucking around with ACLs, if you don't know what you're doing, can seriously break your system in more ways than you can think of. It can also open you up to various attacks because of more relaxed permissions.
If you like what you just read, please subscribe to the feed or follow me on Twitter or any of the other networks I'm registered in to be updated when I post something new.
Comment from: Drew Visitor
Thanks, nice write up explaining things and linking to more content.
This solved exactly the problem you mentioned. Not only were those files unopen-able for me but I also suspect they weren't being indexed or included in file search results.
You might want to juice up you key words or whatever it is that makes this page show up in search results. I had to do a bit of digging to find your solution. i.e. I had to find and search the Windows command before you turned up.
Anyway, fixed things for me.
Comment from: Member
@Drew: What did you search for when you didn't find it, compared to what you searched for when you did? That would be very useful in improving the keywords.
I'm happy that it solved your problem. I banged my head against the wall for several hours myself before I figured it out, while I recovered the computer of a relative.
Comment from: AMD Visitor
I use Permissions Time Machine v1.2 to restore permissions to folder or files or registry keys download it from amyd projects blog
Comment from: Member
AMD: Good hint on the Permissions Time Machine app.