How to hide and unhide a file in the Windows command line
There are two methods of hiding files in MS-DOS or the Windows command line without installing any additional software on the computer.
Hide using the attrib command
The first method is by using the attrib command as seen below.
attrib +h c:\autoexec.bat
This command hides your autoexec.bat file so a standard user browsing your hard drive would not be able to see the file. To make the file unhidden, use -h instead of the +h so the line would look like the example below.
attrib -h c:\autoexec.bat
Although the file is hidden, a user could still type edit c:\autoexec.bat and still be able to edit the file, or if the user typed attrib this would list all files with their attributes.
- See our attrib command page for full information on this command and other examples.
Hide using ASCII characters
The other method uses ASCII characters when creating a directory or renaming it and prevents anyone who is using an early version of Windows and MS-DOS from accessing the directory. Below are the steps required for creating a directory with these characters.
- Type md (hold down Alt and type 987 while continuing to hold Alt, once typed in let go of Alt and you should get a solid block).
- Press Enter to create the directory.
To get into this directory, type cd followed by a space, and hold Alt while typing 987 to get the block. When pressing Enter, you would then be able to get into the directory.
Windows 3.x and Windows 95 will not be able to access these directories, and must be accessed through DOS. However, Windows 98 and later has the capability of opening these directories from within Windows. Therefore, if you are using this method for privacy or security, your procedure could be bypassed.
I can't remember what characters I typed. How do I delete the directory now?
- How do I hide a file or folder in Windows?
- How to see hidden files in MS-DOS and the Command Prompt.
- How do I view hidden files in Windows?
- See the hidden files dictionary definition for further information.
- MS-DOS and Windows command line help and support.