sodcalculator

10 Tech How-To

Fix Folders Reverting to Read-Only in Windows

Guide 10-41998 · Updated · Step by step

If your folders keep reverting to read-only in Windows, the fix is usually to clear the read-only attribute via the command prompt or to correct file permission issues, as the checkbox in the Properties dialog often doesn’t stick. This problem typically stems from Windows marking certain folders as read-only for system protection, or from corrupted attribute flags that need to be reset.

Why Folders Become Read-Only

Windows uses the read-only attribute on folders for a few different reasons, and understanding them helps you choose the right fix. For files, the read-only attribute is straightforward: it prevents writing to that file. But for folders, the attribute works differently. In Windows Explorer, the read-only checkbox on a folder is often grayed out or appears as a square, which confuses many users. This is because the attribute on a folder is used by the system to mark it as a ‘customized’ folder (one where you’ve changed the view settings, like icon size or column layout), not necessarily to make it read-only in the traditional sense.

However, the problem of folders reverting to read-only usually refers to a situation where you try to clear the attribute, and it comes back. This can happen for several reasons:

  • System protection: Windows protects critical system folders (like Program Files or the Windows directory) by setting the read-only attribute. This is normal and should not be changed.
  • File Explorer caching: Windows stores folder view settings in a hidden file called desktop.ini. If this file gets corrupted or is marked read-only, it can make the folder appear read-only.
  • Corrupted attribute flags: Sometimes the attribute itself gets stuck due to a glitch, an interrupted operation, or a third-party program.
  • OneDrive or cloud sync: If the folder is synced with OneDrive, the cloud service can set attributes that conflict with your local changes.
  • User Account Control (UAC): If you’re trying to modify a folder in a protected location (like C:\Program Files), UAC will block your changes and may reset the attribute.

The Command Prompt Fix

The most reliable way to clear the read-only attribute from a folder and all its contents is to use the attrib command in an elevated Command Prompt. This method bypasses the inconsistent behavior of the Properties dialog.

  1. Press Windows Key + X and select Terminal (Admin) or Command Prompt (Admin).
  2. Type the following command and press Enter, replacing "C:\Path\To\YourFolder" with the actual path to your folder:
attrib -r "C:\Path\To\YourFolder" /s /d

Here’s what each part does:

  • -r clears the read-only attribute.
  • /s applies the change to all subfolders and files within the folder.
  • /d applies the change to folders as well (without this, it only affects files).

After running this, check if the folder is still read-only. If it is, you may need to also clear the hidden attribute on the desktop.ini file, which we’ll cover next.

Resetting the desktop.ini File

If the attrib command doesn’t work, the issue might be with the desktop.ini file inside the folder. This hidden file stores folder customization settings, and if it’s marked read-only or corrupted, it can cause the folder to behave oddly.

  1. Open File Explorer and go to the affected folder.
  2. Click View and check the Hidden items checkbox to show hidden files.
  3. Look for the desktop.ini file. If it exists, right-click it and select Properties.
  4. Uncheck Read-only and click OK.
  5. If the file is corrupted, you can delete it. Windows will recreate it automatically the next time you change a view setting in the folder.

If you delete desktop.ini, you’ll lose any custom view settings (like icon size or sort order) for that folder, but the folder itself will not be harmed.

Fixing Permissions with takeown and icacls

Sometimes the read-only attribute is a symptom of a deeper permission problem. If you don’t have full control over the folder, Windows may keep resetting the attribute. Use the takeown and icacls commands to take ownership and grant full control.

  1. Open an elevated Command Prompt as before.
  2. Run the following command to take ownership of the folder and all its contents:
takeown /f "C:\Path\To\YourFolder" /r /d y

This command takes ownership of the folder (/f), recursively (/r), and automatically answers ‘Yes’ to the prompt (/d y).

  1. Next, grant your user account full control:
icacls "C:\Path\To\YourFolder" /grant "%USERNAME%":(OI)(CI)F /T

This grants full control (F) to your username, with object inheritance (OI) and container inheritance (CI), and applies it to all subfolders and files (/T).

After running these commands, the folder should no longer revert to read-only. If you’re still having issues, the problem might be with the folder being in a protected system location, which we’ll discuss next.

When the Folder Is in a Protected Location

If the folder is inside C:\Program Files, C:\Windows, or another system-protected directory, Windows will deliberately keep it read-only to prevent accidental modification. This is a security feature, not a bug. In this case, the best solution is to move the folder to a location you fully control, such as C:\Users\YourName\Documents or another drive.

If you absolutely must modify a folder in a protected location, you can take ownership and change permissions as described above, but be aware that this can weaken system security and may cause issues with Windows updates or other programs. It’s generally not recommended for system folders.

Common Misconceptions

A common misconception is that the read-only checkbox in the folder’s Properties dialog should be unchecked. In many cases, the checkbox is grayed out or shows a square, which is normal. The square indicates that the attribute is set on some items within the folder but not all. If you uncheck the box and click OK, Windows may not apply the change to all subfolders and files, so the attribute appears to revert. The command-line method is the only way to reliably clear the attribute from everything at once.

Another misconception is that a read-only folder prevents you from adding or deleting files. Actually, a read-only folder only prevents you from changing the folder’s own properties (like its name or view settings). You can still create, modify, and delete files inside it, unless the files themselves are read-only. If you’re having trouble writing files, the issue is likely with file permissions, not the folder’s read-only attribute.

Frequently Asked Questions

Why does my folder keep reverting to read-only after I uncheck it in Properties?

Because the Properties dialog only changes the attribute on the folder itself, not on all the files and subfolders inside it. If any file inside the folder has the read-only attribute set, Windows may show the folder as read-only. Use the attrib -r /s /d command to clear it from everything at once.

Can I clear the read-only attribute on a folder in OneDrive?

Yes, but OneDrive may re-set the attribute if it’s still syncing or if the folder is marked as ‘online-only’. Make sure the folder is fully downloaded (right-click and select ‘Always keep on this device’), then run the attrib command. If the issue persists, check OneDrive’s settings or pause syncing temporarily.

Is it safe to delete the desktop.ini file?

Yes, it’s safe. The desktop.ini file only stores folder view settings. Deleting it will reset the folder’s view to the default, and Windows will recreate it when you change a view setting again. It won’t delete any of your files.

Why is the read-only checkbox grayed out on my folder?

That’s normal. The grayed-out or square checkbox means the read-only attribute is set on some items within the folder but not all. To change it for everything, you need to use the command prompt, as the Properties dialog can’t apply the change recursively.

What if the attrib command returns ‘Access denied’?

This usually means you don’t have permission to modify the folder. Make sure you’re running the command as an administrator. If you still get ‘Access denied’, you may need to take ownership of the folder first using takeown and icacls, as described earlier.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →