Today I was helping a Microsoft Windows 10 user that couldn’t read or write to files in a folder on the network. I figured something was set on the files that had them set to Read Only. So I ran the following DOS command on the folder containing the files:
attrib *.* -r +a -s -h /s
Some of the files were changed fine, but others threw an access denied error message. There are a few things to check when this happens. We’ll cover the most common in this guide.
1. Be Sure You are Running the Command With Admin Rights
- Click “Start“, then type “CMD“.
- Right-click on “Command Prompt“, then choose “Run as Administrator“. This will give you proper rights.
- Type the attrib command
2. Check if File is in Use
Are any of the files in use by a program or open on another computer that is connected? Ensure nothing has access to the file when trying to run attrib. If you can’t track down if the file is in use, you may want to try starting the computer in Safe Mode.
3. Check Permissions
Do you have access to all of the files you are running attrib on? You can check this with these steps:
- Right-click the folder you’re working with then select “Properties“.
- Select “Security“.
- Select the “Edit…” button to edit permissions.
- Select “Add…“.
- Type your username to allow just your account access, or type “EVERYONE” to allow access to anybody. Select “OK” when you’re ready.
- With the account you just added higlighted in the “Group or user names” area, select the “Allow” check for “Full control“. Select “OK” when you’re ready.
4. Check File System or Disk
It’s very common for attrib to throw “Access Denied” errors if there is problem with the hard drive. Try running CHKDSK /F
on the drive from a DOS command prompt, then try to run attrib again when it’s finished scanning.
Hopefully, a set of instructions above helped. Please feel free to share your experience in the comments section below.
charles says
Actually, it didn’t help, already went through all the above steps, multiple times.
It says I have full administrative control in group / account. I’m the only user, but I can’t change hidden status in cmd or file explorer.
help???
Rizwan says
Yes it is very useful.
Tahnks a lot.
surinder says
i face the same problem access denied for attrib even after make changes in propties please provied any other solution
Mihai Frumușelu says
Thank you so much, Mitch! I ran it as an administrator and it worked.
TEMITOPE OSANYIN says
Yeah! It helped.
Michael says
This is a very awesome guide. tried different varieties of the attrib command for weeks now and I just keep getting access denied. Tried your attrib string and it finally work. Thank you very much Mitch! you are a gentleman and a scholar.
Ganiyu Sodiq Olaniyi says
Thank you Mitch for this guide. I will add this to my cmd tricks.