How to hide files and folders using attrib.exe command
Sometimes you may need to hide some important files or folders. By hiding the files or folders, we can prevent other users from accessing the files and folders, viewing, deleting or modifying it. We can use Windows attrib.exe command–line tool to configure different attributes for a file or a folder, including hidden attribute.
I suggest you to visit the following links to learn more about file attributes in Windows NTFS file system and attrib command in Windows, before continuing.
Follow below steps to hide a file or folder using attrib.exe tool in Windows Server 2025.
Step 01 – To begin with, let us list the contents of a folder and its attributes using attrib.exe command tool.
PS C:\jajish> PS C:\jajish> attrib.exe C:\jajish\*.* /d /s R C:\jajish\drivers\point64\point64.cat R C:\jajish\drivers\point64\point64.inf R C:\jajish\drivers\point64\point64.sys R C:\jajish\drivers\point64\wdfcoinstaller01011.dll R C:\jajish\drivers\point64 R C:\jajish\drivers PS C:\jajish>
Please note that /d parameter is used to apply attrib.exe and its command-line options to directories also. /s parameter is used to apply attrib.exe command to sub–directories also.
Also note that the R in the above attrib.exe output shows that files and folders are Read–only. From the output of the above attrib.exe command, we can understand that the files and folders are Read–only. There are no hidden files or folders.
Replace the folder path "C:\jajish\*.* /d /s" in attrib.exe shown above according to your requirement.
Please refer the following screenshot.
Step 02 – To make the files and folders hidden, please use attrib.exe command as shown below. Please note that the +h parameter in the above attrib.exe command is used to change the attribute of files and folders to hidden.
PS C:\jajish> attrib.exe +h C:\jajish\*.* /d /s
Please refer the following screenshot.
Step 03 – To check the whether the folders, files and subfolders are hidden now, please run the attrib.exe command again, as shown below.
PS C:\jajish> attrib.exe C:\jajish\*.* /d /s HR C:\jajish\drivers\point64\point64.cat HR C:\jajish\drivers\point64\point64.inf HR C:\jajish\drivers\point64\point64.sys HR C:\jajish\drivers\point64\wdfcoinstaller01011.dll HR C:\jajish\drivers\point64 HR C:\jajish\drivers
The HR characters in the above attrib.exe output shows that files and folders are Hidden and Read–only.
Please refer the following screenshot.
Written by Jajish Thomas.
Last updated on 16th July, 2024.