Attrib doesn’t remove system hidden or read-only attributes from files

by Sep 22, 2025IT Tips0 comments

Windows 2019 Server attrib wasn't removing the system, hidden and read-only attributes as expected.

Make sure you are using an administrative prompt command prompt and then run the command as listed under "# working command" note the addition of "*.*"

# failing command
attrib -s -h -r "E:\dont migrate\Roaming Profiles" /s /d

# working command
attrib -s -h -r "E:\dont migrate\Roaming Profiles\*.*" /s /deee

An example of a script to takeownership of a directory tree remove the system, hidden and read-only attributes, give ownership to a specific account and then robocopy it to a different drive

takeown /f "E:\dont migrate" /r /d y
attrib -s -h -r "E:\dont migrate\*.*" /s /d
icacls "E:\dont migrate" /grant "TOGGEN\toggenadm":F /T /C
robocopy "E:\dont migrate" "Y:\dont migrate" /mir /fft /a-:sh /r:0 /w:0 /log:Y:\dontmigrate.log

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.