How to hide and unhide a file in the Windows command line

Updated: 04/26/2017 by Computer Hope

Windows command line (DOS)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 versions of Windows and MS-DOS from accessing the directory. Below are the steps required for creating a directory with these characters.

  1. 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).
  2. Press enter to create the directory.

To get into this directory, type cd and hold Alt while typing 987 to get the block. When pressing enter you would then be able to get into the directory.

Tip: You can substitute 987, for the dec (decimal) number of any ASCII character.

Note: Windows 3.x and Windows 95 will not be able to access these directories, and must be accessed through DOS. However, users running Windows 98 and above have 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 cant remember what characters I typed. How do I delete the directory now?

See the ASCII dictionary definition that lists a complete listing of ASCII characters or use the "?" wildcard where the ASCII character is.