Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Make Files & Folders Undeletable in Windows

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide shows you how to protect important files and folders from accidental deletion in Windows. You'll learn several methods, from simple permission changes to using built-in security features, so you can choose the one that fits your needs. No extra software is required.

What You'll Need

  • A Windows PC (Windows 10 or Windows 11 recommended)
  • An administrator account (required for some methods)
  • The file or folder you want to protect

Step-by-Step

There are three main ways to make files or folders undeletable. Start with Method 1 for most cases, then try the others if needed.

Method 1: Change Permissions (Most Common)

  1. Right-click the file or folder you want to protect and select Properties.
  2. Go to the Security tab.
  3. Click Edit (under the “Group or user names” box). If you see a warning, click Continue or enter admin credentials.
  4. Select Users (or Authenticated Users) in the list.
  5. In the “Permissions for Users” section, look for Write and Modify.
  6. Check the Deny box for both Write and Modify. This prevents any user (including you) from changing or deleting the item.
  7. Click Apply and then OK.
  8. When asked to confirm, click Yes.
  9. Click OK again to close the Properties window.

Method 2: Use Command Prompt (For Advanced Users)

  1. Press Win + R, type cmd, and press Ctrl + Shift + Enter to open Command Prompt as administrator.
  2. Type the following command and press Enter:
    attrib +r +s "C:\Path\To\Your\File.txt"
    Replace the path with your actual file or folder path. The +r makes it read-only, and +s makes it a system file.
  3. To protect a folder and everything inside it, add /s /d:
    attrib +r +s /s /d "C:\Path\To\Your\Folder"
  4. To undo, replace + with - (e.g., attrib -r -s "C:\Path\...").

Method 3: Use File Ownership (For Extra Security)

  1. Right-click the file or folder and select Properties.
  2. Go to the Security tab and click Advanced.
  3. At the top, next to “Owner”, click Change.
  4. Type Administrators and click Check Names, then OK.
  5. Check the box Replace owner on subcontainers and objects if you want to apply to everything inside a folder.
  6. Click Apply and OK.
  7. Now go back to the Security tab, click Edit, and remove all users except Administrators.
  8. For the Administrators group, set permissions to Read & Execute only (uncheck Modify and Write).
  9. Click Apply and OK.

Common Mistakes

  • Denying permissions to yourself – If you deny all permissions to your own account, you may lock yourself out. Always keep at least read access.
  • Not applying to subfolders – When protecting a folder, changes may not affect files inside unless you check “Replace all child object permissions”.
  • Using “attrib” on folders without /s /d – The read-only attribute alone won’t stop folder deletion; you need the system attribute or proper permissions.
  • Forgetting to take ownership – If you’re not the owner, you can’t change permissions. Take ownership first.

Tips

  • Always test the protection by trying to delete the file or folder. If it asks for permission, it’s working.
  • Keep a backup of important data elsewhere (e.g., external drive or cloud). Protection is not a substitute for backups.
  • For sensitive files, consider encrypting them with BitLocker or EFS instead of just making them undeletable.
  • If you need to edit the file later, temporarily grant yourself write permission, then deny again.
  • Use the Command Prompt method for batch protection of many files.

Troubleshooting

I can’t change permissions – the “Edit” button is grayed out.
You need to take ownership first. Follow Method 3, step 3 to change the owner to Administrators, then try again.

I get “Access Denied” when trying to apply permissions.
Make sure you’re running as administrator. Right-click the file, select “Properties”, go to Security, and try again. If still stuck, open Command Prompt as admin and use the takeown command: takeown /f "C:\path\to\file".

The file still gets deleted after following Method 1.
Check that you selected the correct user group. Also, if the file is on a network drive or cloud-synced folder (like OneDrive), the sync might override permissions. Move it to a local folder first.

I locked myself out – I can’t open the file anymore.
Boot into Safe Mode (hold Shift while restarting, then choose Troubleshoot > Advanced Options > Startup Settings > Restart, then press 4). In Safe Mode, take ownership and restore permissions.

Method 2 didn’t work – the file is still deletable.
The attrib command only sets attributes; it doesn’t prevent deletion by an administrator. Combine it with Method 1 (deny write permissions) for full protection.

Frequently Asked Questions

Can I make a file undeletable without admin rights?

No, most methods require administrator access because they change system-level permissions. If you don’t have admin, you can only set the read-only attribute, which is easy to bypass.

Will these methods protect against malware or ransomware?

No. Malware runs with your user permissions and can often bypass these protections. For real security, use antivirus software and offline backups.

Can I still read the file after making it undeletable?

Yes, if you keep read permissions. In Method 1, you only deny Write and Modify, so you can still open and view the file.

How do I undo the protection?

Go back to the Security tab, uncheck the Deny boxes, or run attrib -r -s in Command Prompt. You may need to take ownership again if you used Method 3.

Does this work on external drives or USB sticks?

Yes, if the drive is formatted with NTFS. FAT32 drives don’t support permissions, so use the attrib method instead.

Will this prevent Windows from updating the file?

If the file is a system file, denying write access may cause updates to fail. It’s best to protect only personal files, not system files.