9

I have a problem with the write protection of Windows 7. All my files in my users folder are protected and it is impossible to remove. When I uncheck the checkbox, a progressbar runs threw but everything stays unchanged. I've also tried to change it in the command line with

attrib -r C:\Users\Username\*.* /d /s

but nothing has changed. What else can I try? Thanyou!

skotschi
  • 91
  • 1
  • 1
  • 2
  • I am desperate. I've tried everything. chkdsk.exe doesn't help, check disk on start-up doesn't help. I can't even download music from the iTunes store because the entire library is locked. – skotschi Apr 28 '11 at 14:02
  • What version of Windows 7? – Supercereal Apr 28 '11 at 15:04
  • The /d switch in your command line means it will apply only to directories, and the ReadOnly attribute on directories is pretty much meaningless. If you cannot create files in those directories, there is something else preventing it, such as permissions. – kreemoweet Jan 31 '12 at 05:52
  • @kreemoweet, you can use the attribute to give folders their own icons. `;-)` But yes, the problem should be solved by running it again without the `/d` switch to strip the read-only attribute from files. – Synetech Sep 04 '12 at 15:59
  • 1
    Do you have write permission for the files? In the GUI, right click on the directory, go into the security tab, and give yourself full control. Then, try to change the attributes again. – Konstantin Tarashchanskiy Sep 04 '12 at 16:16

6 Answers6

1

Old question, I understand. But since the one answer doesn't give any details, let's add some details.

In modern (NT-based) Windows, that is all Windows versions released since 2000 (inclusive), there are two things that govern write access:

You are attempting to modify the former, but seem to expect the result you'd get from modifying the latter. The reason I can make this claim is because it's the only possibility left (aside from malware and such), when you witness attrib not working. It's kind of akin to trying chmod on Linux and getting access denied because someone used chattr +i on the file/folder previously (which doesn't show up as a file mode).

Suppose your principal (i.e. your user in the sense of a user context) has full access to a file, it can simply remove the (DOS-)attribute the way you tried. But if you aren't the owner and aren't explicitly given permission to access a file or directory, you don't have access. The more extreme form is that someone explicitly denied you access (we'll get there at the very end).

Suppose you don't have access to an object on Windows, there's nothing you can do about it, unless you happen to be the owner of the machine and therefore can also elevate yourself to a privileged user context.

If that's the case you can use the command line tool icacls, successor to the older cacls (which has no idea about inheritance, the i in icacls), to reset the ACLs:

icacls * /T /Q /C /RESET

The /T applies the operation to all matching files and directories. /Q suppresses success messages and /C continues in case of errors. The /RESET will reset the ACLs with default inherited ACLs (from the parent container). That last point is important, because this won't work unless you also have access to the parent container.

The effect should be the same you'd expect from copying your files off of your disk to a FAT-formatted thumb drive and back. Simply because copying back from a FAT-formatted drive (which knows no ACL) will reset the ACLs to be inherited from each respective parent container.

Simply using icacls with a file/folder name will yield the ACL as output for inspection. But you can also right-click a file or folder and select the "Security" tab (also something mentioned in Linda's answer already):

Security tab in properties dialog of C:\Windows folder on a Windows 10

Suppose you still don't have any permission to a certain type of access, you'll want to click the "Advanced" button (in the dialog shown above) and change the owner:

Advanced Security Settings dialog

This, however, can also be done with icacls /setowner ...

And that's last bit is what is required if you want to gain access to an object (or hierarchy of objects) to which you have been explicitly denied access (Deny ACEs take precedence over Allow ones) or if the objects are owned by someone else and you haven't been given access.

However, this is getting you into "deeper waters" than you may want to venture to without reading up on the NT security model and how principals, ACLs and ACEs relate to each other. In short: get a friend with enough knowledge about these matters to help you. Taking ownership of objects carries its own risks, which is why that privilege is only bestowed on admins (and the TCB) by default.


How did we get here?

Suppose you don't have malware that plays a nasty prank on you, you don't give something like %HOMEPATH% or %USERPROFILE%, so perhaps this isn't actually your profile? Perhaps you're attempting to access C:\Users\username when your current profile is actually C:\Users\username.000?!

This could conceivably happen if you upgraded to Windows 7 and your previous profile remained under that username. It could be a changed SID for the system. Perhaps you forgot to mention that the files came from elsewhere or had been restored from a backup of a system with another SID. There's a multitude of possibilities of what could be the cause for what you're seeing.

Another possibility is that the drive on which your C:\Users resides is read-only (in case you used a reparse point of some sort to divert C:\Users), although I'd expect logon issues in this case. So I'll refer back to the profile folder issues I mentioned before.

Malware is indeed a possibility, but without an offline scan (i.e. boot with a CD/DVD and scan the system drive and all other drives of your Windows system) and under the assumption that the used AV knows about that malware, you may never know. And frankly whenever I've seen this in the past, the inspection of the (DOS) file attributes and the ACLs of all involved objects (including the parent containers) would at least give a clue, because they would indicate that the object should be accessible (e.g. icacls) but the fact that it's not would hint at the malware. So while I'm not precluding this, it's still likely not your issue.


Long story short, had I seen this question some years earlier, I would have asked for more details from you. As it stands too much is left to guessing, although restrictive ACLs seem like the most likely cause.

0xC0000022L
  • 6,819
  • 10
  • 50
  • 82
0

May be you do not have needed access rights for this folder? In this case login in Windows as Admin, open this folder (C:\Users\Your user) and change (add ownership as Your user) access rules (Properties->Security->Edit) to this folder.

Linda
  • 11
-1

Download Hiren Boot Cd 15.2, burn to CD, then boot your computer from CD. Executes the mini version of Windows XP. Optimizations in the disk section there is a simple application to reset the NTFS permissions of a folder or entire disk.

KakashiSan
  • 89
  • 2
-2

Try a chkdsk.exe C: to do a basic check of the disk. Sometimes this fixes your problem. Make sure to use an elevated command line.

Peter Hahndorf
  • 13,370
  • 9
  • 51
  • 67
  • When I start the chkdsk.exe the first thing it says is: Warning! The parameter F wasn't stated. chkdsk works in protected mode. Sorry if it istn't the acurate warning, but I have to translate it. – skotschi Apr 23 '11 at 20:47
  • @skotschi, see this...http://www.howtogeek.com/howto/windows-vista/guide-to-using-check-disk-in-windows-vista/ – Moab Apr 24 '11 at 03:22
  • @skotschi simply means it won't fix any issues it may find. Nothing wrong leaving off `/f`. If errors are found - at least in recent versions of `chkdsk` - you'll be instructed to add `/f` and invoke it again. – 0xC0000022L May 18 '20 at 11:31
-2

Maybe it is a virus?
I saw joke-viruses like that. They lock files simply opening them in "lock read write" mode. Try Sysinternals' Handle.exe . If the files are locked with that method, Handle will give you the name of locker.

Searush
  • 817
  • 2
  • 10
  • 20
-2

Move the files to a fat or fat32 formatted thumbdrive (or any drive) and back.

Colyn1337
  • 1,228
  • 9
  • 24
  • Can you expand, maybe to explain *why* moving files to a FAT-formatted partition would allow this to work? Maybe also mention any limits of using a FAT-style partition (i.e. limited to 4GB file size, unless you're using exFAT)? – Canadian Luke Jun 20 '14 at 15:23
  • 1
    @CanadianLuke yep, because in all likelihood it will reset the [ACLs](https://docs.microsoft.com/en-us/windows/win32/secauthz/how-dacls-control-access-to-an-object). – 0xC0000022L May 18 '20 at 11:29
  • 1
    @0xC0000022L That was an attempt to get the answerer to edit their answer to include more than a sentence :P – Canadian Luke May 18 '20 at 16:15
  • @CanadianLuke ah, apologies. I didn't read between the lines there. – 0xC0000022L May 18 '20 at 19:16
  • @0xC0000022L ignore the pedanticism. – Colyn1337 May 19 '20 at 20:18