Fix Attrib Command Not Working (3 Ways)

Get the possible cause of the "attrib command not working" issue below and fix it separately with 3 proven ways!

By @Penny Last Updated September 13, 2024

“I want to retrieve my files on my flash drive and then I tried this one: -s -r -h /s /d, but the result is: '-s' is not recognized as an internal or external command, operable program or batch file. How can I solve this one ?” – superuser

“I'm trying to change a file within a game I have installed on my computer, but the read only attribute won't change. I've researched this and found a way using the command prompt where I can change the attributes of the files; specifically the read only attribute.

The command I was given is: attrib -s-r C:\/d/s. Thus, I opened a command prompt and typed in: attrib-r-s/d/s. But each time the result is: The filename, directory name, or volume label syntax is incorrect. I've tried copying and pasting the file path, or typing it manually, but it still won't work. I can't seem to work out what's wrong. Any ideas?” – spiceworks

💬 If you want to skip the basic knowledge to directly fix the "attrib command not working" issue, please go to the corresponding solutions. To recover deleted files instead of hidden files, try data recovery software - MyRecover instead.

What is the attrib command?

ATTRIB is a Microsoft command in all versions of Windows that displays or changes the file attribute of a file or folder. To be more precise, the attrib command allows users to modify and set file attributes read-only, hidden, system, and archive

For example, in early versions of Windows, a temporary file only can be read and was also locked (and irrevocably) by Windows OS. In this case, there is no better way to delete this file than by booting into DOS (avoiding the Windows lock) and modifying the read-only attribute with the attrib command.

New versions of Windows also have seen the extension of the inventory of available attributes on the NTFS file system. Here, you’re supposed to be familiar with these four conventional attributes in Microsoft Windows, files, and folders.

Read-only (R): Users have no written permission to alter or change the read-only file.

Hidden (H): MS-DOS commands like dir and Windows apps like File Explorer will not show hidden files by default, making files or folders invisible to users.

System (S): Mark the file as an important file system, and change the priority of the file.

Archive (A): The hosting file has been changed since the last backup. Then backup software will inevitably clear it after making a full/incremental backup.

Why is the attrib command not working?

As stated earlier, attrib is a very useful command to help us show hidden files, remove read-only attributes, etc., within easy-to-follow steps. But sometimes, users find the attrib command is not working. We collect some of the main reasons for this, just for reference.

  • Type the format of the attribute command wrongly.
  • The path of environmental variables is not starting with C:\Windows\System32.
  • You use the attrib command to recover deleted files instead of hidden files.

So you’d better tweak your thoughts, and follow the corresponding solutions to fix the "attrib command not working" issue. If your files are deleted, take Windows data recovery software into account.

How to fix the attrib command not working issue efficiently 

Ready? Let's get started to fix the "attrib command not working" issue based on the corresponding cause. First, you must DON'T want to screw up everything by typing the attrib command correctly. Please check the Way 1 before attempting other 2 methods.

Fix 1: Type attrib command correctly

Before trying to show hidden files, remove read-only attributes, etc., please be sure the following items while using the attrib command.

✦ you are using an admin account or running cmd.exe as administrator ✦ include spaces in the command. ✦ not using< >in the pathname. < >is usually a convention meaning you have to substitute something for . ✦ If there are spaces in the filename, use quotation marks. ✦ using backslashes \ not forward slashes / in the pathname

Now, follow the steps below to get started.

Step 1. Type cmd in the search box and select Run as administrator.

Step 2. To remove read-only attributes, type the following command and press Enter

attrib -r -s C:\file name /d /s

or 

attrib -r -h -s "C:\file name" /d /s

Step 3. To show hidden files, type the command as follows and press Enter. Replace the drive letter with your own. 

attrib -h -r -s /s /d drive letter:\*.*

Fix 2. Modify the path of environmental variables

Using the incorrect environmental variables path may be another possible cause of the "attrib command not working" issue.  Try to change it to C:\Windows\System32.

Step 1. Right-click My Computer, and select Properties > Advanced System Settings.

Step 2. In the Advanced System Settings window, click Environment variables.

Step 3. Scroll down to System variables and look for Path.

Step 4. Click Edit and add C:\Windows\System32 at the end of the string. Make sure you don't delete the rest of the string.  

Fix 3: Recover deleted files using data recovery software

If your purpose is to recover deleted files, try reliable data recovery software. You have two options in the following:

Option 1: Microsoft's official data recovery software - Windows File Recovery. 

Released in 2020, it's a command line tool designed to recover deleted files from HDD/USB/memory card/SD card and free. But it has two biggest issues, namely lack of a graphical user interface and require you to learn many obscure parameters. In addition, it still has many limitations. So it will not be a good choice. Click how to use Windows File Recovery to learn more. 

Option 2: 3rd party software - MyRecover

Also, you can try 3rd party software - MyRecover, embedded with a clear GUI and strong technologies, which take care of fast scanning and a high success rate of data recovery in 3 steps. With it, you can recover deleted files in Windows 7, 8, 10, 11, and Windows Server easily and quickly. 

 MyRecover
Powerful Data Recovery Software for Windows
  • Two crucial scanning algorithms: scan disk with Quick Scan & Deep Scan quickly and thoroughly for deleted or lost files, laying the basis for a high success rate of data recovery.
  • Over 200 types of data: recovering files, from documents (e.g. recover deleted Word) to images, videos, compressed files, emails, etc., up to 200+ formats.
  • Highlight features: filter and preview data before recovery. recover files from hard drive without OS.
  • Various storage devices: compatible with different storage devices, such as HDDs/SSDs, external disks, USB drives, SD cards, digital cameras, etc., and NTFS/FAT32/exFAT file systems.

Now, download the free data recovery software - MyRecover and install it on a working computer for data recovery.

Step 1. Open MyRecover. Hover the mouse over the drive and click Scan to scan.

Step 2. This tool will perform Quick Scan and Deep Scan automatically. Once found, your deleted files and other lost files will be shown on the screen respectively.

Step 3. Select the desired files and click  “Recover x files”. Specify another destination partition or folder to save your recovered files.

To select deleted or lost files,  you have two ways in the following:

 Through sidebar directories: Expand Deleted files, go to the original location of deleted files, and select them. 

 Use the file filter feature: Click the Filter feature, displayed as a funnel-shaped button, and select Type > Documents. Then, type the file name or .xlxs in the search box to narrow it down. 

⚠️Notes:
  • The x refers to the number of selected files. The total size is also included.

  • Don't save the recovered files to the original location as it may cause data overwriting. 

  • You are allowed to recover deleted files during the scanning process.

 After that, go to your destination place to check your recovered files.

Bonus tip

This tutorial helps you clarify the definition of attrib and its reasons for the attrib command not working. Maybe you have a clear understanding of hidden files and know how to easily fix this issue now.

Please be sure you type the attrib command correctly, whether you want to show hidden files or remove read-only attributes. In addition, you can also change the path of environmental variables and recover deleted files using data recovery software like MyRecover. 

If you’ve already experienced the agony of data loss and don’t want to go through it again. You’d better create regular backups using the freeware - AOMEI Backupper to make automatic full, incremental, or differential backups in terms of files, partitions, or disks.