ThisCalculator

Everyday

Make Files Undeletable in Windows: 5 Ways

Updated · Standard formula, shown below

You can make files undeletable in Windows by changing file permissions, using the built-in encryption, or setting the read-only attribute, though each method has limits. The most reliable way is to deny delete permissions for your user account via the file’s Properties > Security tab, which stops accidental deletion in File Explorer. This guide explains the practical methods, their trade-offs, and how to undo them.

Why Files Get Deleted (and What “Undeletable” Really Means)

Windows deletes a file when the user account has the “Delete” permission and the file isn’t locked by a running program. The Recycle Bin offers a second chance, but Shift+Delete or a script bypasses it. When people say “undeletable,” they usually mean one of three things:

  • Protected from accidental deletion – a confirmation prompt or permission block.
  • Protected from deliberate deletion by other users – permissions that deny delete for specific accounts.
  • Protected from deletion even by an administrator – requires special ownership or system-level locks (rarely needed).

No method makes a file 100% undeletable against a determined administrator or a disk wipe. But for everyday protection, permissions and attributes are sufficient.

Method 1: Deny Delete Permissions (Most Effective)

This works on NTFS drives (the default for Windows system drives). It prevents the file from being deleted, renamed, or moved by the user who owns it.

  1. Right-click the file or folder → Properties.
  2. Go to the Security tab → click Advanced.
  3. Click Disable inheritance → choose Convert inherited permissions into explicit permissions.
  4. Click Add → Select a principal → type your username → OK.
  5. In the Permission entries window, set Type to Deny.
  6. Check the box for Delete and Delete subfolders and files (if a folder).
  7. Click OK on all dialogs. Windows will warn that deny rules take precedence – confirm.

Now if you try to delete the file, you’ll get an “Access Denied” error. To undo, go back to Advanced → select the Deny entry → Remove.

Caveat: This only works if the file is on an NTFS volume. If it’s on a FAT32 or exFAT drive (common for USB sticks), permission settings are ignored.

Method 2: Read-Only Attribute (Simple but Weak)

The read-only attribute is the oldest trick. It prevents modification but not deletion in most cases – Windows will still let you delete a read-only file, but it asks for confirmation.

  1. Right-click the file → Properties.
  2. Check the Read-only box under Attributes.
  3. Click OK.

This is more of a deterrent than a lock. It works for files you rarely touch, but it won’t stop a determined user or a script that uses the del /f command (which forces deletion of read-only files).

Method 3: Encrypt the File (EFS)

Encrypting File System (EFS) is built into Windows Pro, Enterprise, and Education editions (not Home). It encrypts the file with your account’s key. If another user tries to delete it, they’ll get an access denied because they don’t have the decryption key. However, the owner can still delete it normally.

  1. Right-click the file → Properties → Advanced.
  2. Check Encrypt contents to secure data → OK.
  3. Apply – Windows will ask if you want to encrypt the folder instead (choose “only this file” if you want).

This is not a deletion protection per se – it’s encryption that happens to block other accounts from accessing the file, which includes deleting it. The downside: if you lose your password or the system is reinstalled, the file becomes permanently unreadable.

Method 4: Take Ownership and Lock with Permissions (Advanced)

If you want to make a file undeletable even by administrators (including yourself), you can set permissions so that only the SYSTEM account has full control, and deny everyone else. This is risky and not recommended for normal use.

  1. Right-click the file → Properties → Security → Advanced.
  2. Click Change next to Owner → type SYSTEM → OK.
  3. Now remove all other permission entries except SYSTEM.
  4. Add a Deny rule for “Everyone” with Full control.

Now even an administrator can’t delete the file without first taking ownership (which requires the “Take Ownership” privilege). This is how some malware protects itself. To undo, you’d need to boot into a recovery environment or use a Linux live USB to reset permissions.

Method 5: Use Command-Line Attributes (attrib + icacls)

For advanced users, the command line gives more control and can be scripted.

  • attrib +r file.txt – sets read-only.
  • icacls file.txt /deny "%USERNAME%":(DE) – denies delete permission (DE = delete).
  • icacls file.txt /remove:d "%USERNAME%" – removes the deny rule.

These commands work in an elevated Command Prompt (Run as administrator). The icacls method is equivalent to the GUI method but faster for multiple files.

Common Problems and How to Fix Them

  • “Access Denied” even after removing deny rule – You may have denied yourself the ability to change permissions. Reboot into Safe Mode or use a recovery tool to take ownership.
  • File is on a USB drive with FAT32 – Permissions don’t apply. Convert the drive to NTFS (right-click → Format → NTFS) or use a different method.
  • You can’t see the Security tab – This happens on FAT32/exFAT drives or if Simple File Sharing is enabled. Convert to NTFS or disable simple sharing.
  • Read-only doesn’t work – Some programs (like Word) can still delete read-only files if they have the right permissions. Use the deny method instead.
  • Encrypted file shows a lock icon – That’s normal. If you can’t open it, you lost the encryption key. Back up your EFS certificate.

What NOT to Do (and Safer Alternatives)

Don’t use third-party “file locker” tools that hook into the file system – they often break after Windows updates and can cause system instability. Don’t set permissions on system files (like in C:\Windows) – you can break Windows. Instead, consider these safer alternatives:

  • Move the file to a protected folder – e.g., inside your user profile, which already has restrictive permissions.
  • Use OneDrive or a cloud service – Version history lets you recover deleted files.
  • Back up regularly – The best protection against deletion is a copy elsewhere.
  • Use File History – Windows built-in backup can restore previous versions.

Frequently Asked Questions

Can I make a file undeletable on a FAT32 USB drive?

No, FAT32 doesn’t support permissions. You can set read-only, but that only prevents modification, not deletion. To get true deletion protection, format the drive to NTFS (right-click → Format → File system: NTFS) and then use the deny method.

Will the deny method work if I’m an administrator?

Yes, because deny rules take precedence over allow rules, even for administrators. However, an administrator can always take ownership and change permissions, so it’s not a security boundary – it’s a deterrent against accidental deletion.

How do I undo the deny permission if I get locked out?

Boot into Safe Mode (hold Shift while clicking Restart → Troubleshoot → Advanced options → Startup Settings → Restart → press 4). Then log in as Administrator, which may bypass the deny rule, and remove it. If that fails, use a Linux live USB to edit the file’s ACLs.

Does read-only prevent deletion in Windows 11?

No. Read-only only prevents modification. Windows will ask for confirmation when deleting a read-only file, but it will still delete it. Use the deny method for actual protection.

Is there a way to make a file undeletable without changing permissions?

Yes, you can use the built-in BitLocker to encrypt the whole drive, which prevents other users from accessing the file system entirely. But that’s overkill for one file. Alternatively, you can store the file in a password-protected ZIP archive – the file inside can’t be deleted without the password.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.