How to hide or unhide folder with denied access permission by command prompt in Windows

Introduction

In this article we will discuss about, how to hide or unhide folder or file using attrib windows command and how to deny access permission on hidden folder by cacls command. By attrib command we can hide our folder or file which won’t be viewable by don’t show hidden files, folders, or drives option and by cacls command we can deny access permission on the same file or folder for additional security.

What the purpose of attrib command is

The attrib command is a Windows command, the main purpose of this command is to remove and set file attributes (hidden, read-only, system and archive), hence it allows a user to display, set or remove the read-only, hidden and archive file attributes assigned to a file or folder.

There are four attributes in a windows file

  • Hidden: It makes files or folders invisible.
  • Read-only: It provides the read-only attributes to the file, in other words no one can delete or make changes to that specific file that has the read-only attribute.
  • Archived: Provide a backup of file. Hence help in recovering of files.
  • System: Mark the file as an operating system file.

Parameters of attrib command

  • +s: Used to set the file or folder attribute as a system file.
  • -s: Used to clear the system file or folder attribute.
  • +h: Used to make the file or folder attribute as hidden not visible to the user.
  • -h: Used to clear the hidden file or folder attribute.
  • +r: Used to set the file or folder attribute as read-only.
  • -r: Used to clear the read-only file or folder attribute.
  • +a: Used to set the file or folder attribute as archive.
  • -a: Used to clear the archive file attribute.

How to hide or unhide a folder or file

Step 1: Open the Command Prompt

Use window key + R and on the run window type cmd and enter. Or open command prompt from startup menu.

Step 2: Now go to your folder (which you want to hide) location by command prompt

Step 3: Use attrib +s +h +r <folder Name> to hide your folder

Now your folder is hidden, Go to the folder location in windows explorer and check that your folder is not visible, even when you show your hidden folder through Organize à Folder and search options à show hidden files, folders, or drives then also your folder is not visible.

Note:

To access files of your folder, enter full path of files (up to folder name) To view all of your hidden folder go to organize à Folder and search options à Hide protected operating system files (uncheck it) and select show hidden files, folders, or drives. Note: Just delete recent visit list so the vary folder will be hidden to everyone as it won’t be in recent visit list and also it won’t be viewable on drop down in explorer.

What is the purpose of cacls command?

The cacls command is used to display or modify Access Control Lists (ACLs) for files and folders. Access Control Lists apply only to files stored on an NTFS formatted drive, each ACL determines which users (or groups of users) can read or edit the file. When a new file is created it normally inherits ACL’s from the folder where it was created.

Syntax

  • CACLS pathname [options]

Options

  • /T Search the pathname including all subfolders.
  • /E Edit ACL (leave existing rights unchanged)
  • /C Continue on access denied errors.
  • /G user:permission Grant access rights, permission can be:
  1. R Read
  2. W Write
  3. C Change (read/write)
  4. F Full control
  5. N None
  • /R user

    Revoke specified user’s access rights (only valid with /E).

  • /P user:permission Replace access rights, permission can be:
  1. R Read
  2. W Write
  3. C Change (read/write)
  4. F Full control
  5. N None
  • /D user

    Deny access to user.

  • /s:sddl

    Replace the ACL(s) with those specified in the SDDL string (not valid with /e, /g, /r, /p, or /d).

Note: In all the options above “user” can be a Username or a group (either local or global)

How to deny access to all user

As if now we have hide our folder by attrib command. Now follow below step to restrict the access permission.

Step 4: Enter cacls /e /p everyone:n in the command prompt.

Note: Now no one has the access to open the folder hence if you enter full path of files path (up to folder name) in your explorer then it will show excess denied pop up.

How to get access to folder and then unhide folder

As if now we have denied the access to the Games folder and hide it by attrib command. To get the access to the folder and unhide it, follow below steps.

Step 1: Go to the command prompt and enter cacls /e /p everyone:f command to get full access.

Or you can follow below step to get access to your folder. Go to organize à Folder and search options à Hide protected operating system files (uncheck it) and select show hidden files, folders, or drives. Then right click on the folder and go to Properties then go to security tab then select everyone and then click on edit it will pop up a new window, then check allow full control and then click ok and then on the previous window (security tab) click ok.

Step 2: Use attrib –s –h –r to unhide your folder.

Now your folder is viewable and accessible like all other folders. Note: you can follow same procedure on a file as well. J

Watch on you tube

Advertisements

About Sanjay Madnani

Software Developer.
This entry was posted in Tricks, Windows and tagged , , , , , , , , , . Bookmark the permalink.

3 Responses to How to hide or unhide folder with denied access permission by command prompt in Windows

  1. Bajrang says:

    Good Work. I prefer the change the registry of the folder, and, hide it, and, attrib.

    CACLS is new.

  2. Sushil Madnani says:

    Well done Sanjay, please keep doing this informative work.

  3. Sunil. says:

    Thanks Sanjay. Its a useful information.
    Cheers.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s