attribattrib +h +s Command: Hide and Mark as System
Learn how to use attrib +h +s to set Hidden and System attributes, when to use it, and how to reverse it safely.
The attrib +h +s command sets both the Hidden and System attributes on a file or folder, making it less visible in normal Windows Explorer views and marking it as a system file. This is often used to protect sensitive system files, hide configuration data, or restore default attributes after maintenance.
Whether you are a system administrator protecting critical files, a developer managing configuration artifacts, or an IT professional restoring system defaults after troubleshooting, attrib +h +s provides a direct way to apply both attributes from the command line.
This guide covers syntax, examples, use cases, troubleshooting, related commands, FAQs, and a quick reference card. By the end, you will know when and how to set or clear Hidden and System attributes safely.
What Does attrib +h +s Do?
attrib +h +s applies two attributes at once:
- Hidden (H): Hides the file or folder from normal Explorer views unless hidden files are shown.
- System (S): Marks the file as a system file, which can further hide it and signal Windows to treat it as a protected item.
These attributes are often used together for system files or application data that should not be casually modified.
Syntax
attrib +h +s [drive:][path][filename] [/S] [/D]
Parameters and Options
| Parameter | Description | Example |
|---|---|---|
+h | Set Hidden attribute | attrib +h file.txt |
+s | Set System attribute | attrib +s file.txt |
/S | Apply to files in subdirectories | attrib +h +s C:\Data\*.* /S |
/D | Include directories | attrib +h +s C:\Data /S /D |
Examples (HowTo)
1. Hide a single file as system
Scenario: You want to protect a configuration file from casual viewing.
attrib +h +s C:\App\config.ini
Explanation: The file becomes hidden and marked as a system file.
2. Hide a folder and all contents
Scenario: You need to hide a folder structure and mark it as system data.
attrib +h +s C:\AppData\MyApp /S /D
Explanation: Applies attributes to all files and folders under the path.
3. Restore visibility by removing attributes
Scenario: You need to unhide a file for editing.
attrib -h -s C:\App\config.ini
Explanation: Clears Hidden and System attributes so the file appears normally.
4. Verify attributes before and after
Scenario: You want to confirm changes took effect.
attrib C:\App\config.ini
attrib +h +s C:\App\config.ini
attrib C:\App\config.ini
Explanation: The output shows attribute letters before the filename.
5. Apply to a group of files
Scenario: You want to hide all .dat files.
attrib +h +s C:\Data\*.dat
Explanation: All matching files receive both attributes.
6. Hide system files after maintenance
Scenario: You edited the hosts file and want to restore protection.
attrib +h +s C:\Windows\System32\drivers\etc\hosts
Explanation: Restores Hidden and System attributes after editing.
Common Use Cases
-
Protect configuration files – Hide and mark config files as system to reduce accidental edits.
-
Restore system defaults – Reapply attributes after troubleshooting or maintenance.
-
Hide application data – Keep application data folders out of normal view.
-
Legacy compatibility – Some apps expect system-marked files.
-
Malware cleanup verification – Confirm which files are hidden and system-marked.
-
Migration prep – Mark sensitive files before packaging.
-
Kiosk systems – Hide system assets from users.
-
Training labs – Prevent accidental file changes by students.
-
Backup workflows – Preserve attribute state before backup.
-
Incident response – Reapply attributes after restoring critical files.
Tips and Best Practices
-
Use /S and /D cautiously – Recursive changes can affect large directories.
-
Document attribute changes – Keep a record of files you hide.
-
Verify with attrib – Confirm attributes after changes.
-
Do not rely on hidden for security – Hidden is obscurity, not access control.
-
Use NTFS permissions for real protection – Combine with icacls when needed.
-
Avoid hiding system-critical files unnecessarily – It can confuse troubleshooting.
-
Use quotes for paths with spaces – Prevent command parsing issues.
-
Clear both attributes together –
-h -sis safest for system files. -
Check with DIR /A – Confirm visibility with attribute-aware listing.
-
Run as Administrator when needed – System files may require elevation.
Troubleshooting Common Issues
"Access is denied"
Problem: The command fails on protected files.
Cause: Lack of permissions or file in use.
Solution: Run CMD as Administrator and close applications using the file.
Prevention: Use elevated sessions for system directories.
Attributes do not change
Problem: The file remains visible or unchanged.
Cause: System protection or wrong path.
Solution: Verify the path, use attrib to check current attributes, and run as admin.
Prevention: Confirm with DIR and full paths before applying.
Hidden files still show in Explorer
Problem: File is still visible.
Cause: Explorer is set to show hidden and system files.
Solution: Adjust Explorer options or verify attributes with attrib.
Prevention: Use attribute checks instead of Explorer visibility.
Recursive change too broad
Problem: Too many files were hidden.
Cause: Using /S /D on a broad path.
Solution: Use attrib -h -s on the same path to revert, then target a narrower path.
Prevention: Test on small directories first.
Related Commands
attrib -h -s
Clears Hidden and System attributes when you need to restore visibility.
dir /a
Lists files with attributes so you can verify hidden/system status.
icacls
Controls NTFS permissions for real security, beyond hidden attributes.
takeown
Changes ownership for protected files that require attribute updates.
compact
Manages NTFS compression attributes, often used with attrib workflows.
Frequently Asked Questions
What does attrib +h +s do?
It sets both Hidden and System attributes, making files less visible and marking them as system files.
Is this secure protection?
No. Hidden/System attributes are not access control. Use NTFS permissions for security.
How do I reverse attrib +h +s?
Use attrib -h -s path to clear both attributes.
Does it work on folders?
Yes. Use /D to include directories when applying attributes recursively.
Can I apply it recursively?
Yes, use /S /D to apply to files and directories under a path.
Why do I still see the file?
Explorer may be configured to show hidden and system files. Verify with attrib.
Do I need admin rights?
For system paths, yes. Regular files may not require elevation.
Can malware abuse these attributes?
Yes. Malware often hides files using +h +s. Always inspect with security tools.
Quick Reference Card
| Command | Purpose | Example |
|---|---|---|
attrib +h +s file | Hide and mark system | attrib +h +s C:\App\config.ini |
attrib -h -s file | Unhide and clear system | attrib -h -s C:\App\config.ini |
attrib +h +s C:\Path /S /D | Apply recursively | attrib +h +s C:\Data /S /D |
dir /a | View attributes | dir /a |
CTA: Practice and Explore
Practice attrib commands in the Windows Command Simulator and browse the Commands Reference for related file tools like attrib, dir, and icacls. Learn more about this project on the About page.
Summary
attrib +h +s applies Hidden and System attributes to files or folders, making them less visible and marking them as system items. It is useful for restoring default protections, managing configuration files, and controlling visibility during maintenance or deployments.
Always verify with attrib or dir /a, and remember that hidden attributes are not security. For real protection, use NTFS permissions and document changes in production environments.