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 uses 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, someone could still type edit c:\autoexec.bat and edit the file, or if someone typed attrib it lists all files and their attributes.
Hide using ASCII characters
The other method uses ASCII characters when creating a directory or renaming it and prevents anyone 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 a solid block appears).
- 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 cannot 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.