Fix the error a file is protected and cannot be used with this command
Solved Email & Outlook
BA
Barry Allen
February 8, 2021
2 replies
6,340 views
Reviewed by moderators

An operation on a file fails saying the file is protected and cannot be used with this command. The file is mine and I need to work with it.

What kind of protection triggers this and how do I clear it?

Accepted Answer
Verified by Kerry Morris, Forum Moderator ยท Reviewed February 2021

This message covers a few different protections depending on the file and the operation, so the fix is identifying which is in play, checked in order of likelihood for a file you own:

Read only or system attributes, the common cause: a file marked read only, or hidden and system, refuses operations that need to modify it. Right click, Properties and uncheck Read-only or from a command prompt attrib -r -s -h filename clears the read only, system and hidden attributes that block modification. This resolves the most frequent version, an attribute preventing the command from acting on the file.

The Mark of the Web block, for files from elsewhere: a file downloaded or copied from another computer carries the from another computer tag that can block certain operations, cleared by right clicking, Properties and checking Unblock or PowerShell's Unblock-File, covered in the unblock thread linked alongside. If the file came from outside this machine, this is a likely cause.

Permissions, when the file resists attribute changes: NTFS permissions denying your account access produce protection style refusals, fixed by right clicking, Properties, Security and ensuring your account has the needed permission, taking ownership via Advanced if the file's ownership is the obstacle, which happens with files from another user account or system. Taking ownership and granting yourself full control clears permission based blocks on files you are entitled to.

Encryption or application protection, the specific cases: an EFS encrypted file needs the right certificate to use, and an application level protection, a password protected document or a rights managed file, needs its own credential rather than an attribute change, so if the file is genuinely encrypted or rights protected, the fix is the appropriate credential or certificate, not an attribute clear. Matching the fix to which protection the file actually has is the whole task, most cases being the simple read only or attribute cause that attrib clears, with permissions and Mark of the Web the next most common and genuine encryption the case needing real credentials.

It was the read only attribute plus it had come from another PC so also the Mark of the Web, cleared both with attrib and Unblock and the command worked. The identify which protection applies approach was right, I had assumed something complex when it was two simple attributes stacked. Working with the file now.