# How to deny any file opening in a specific folder

**URL:** <https://forums.powershell.org/t/how-to-deny-any-file-opening-in-a-specific-folder/20488>\
**Category:** PowerShell Help\
**Created:** [September 21, 2022, 7:53am UTC](https://forums.powershell.org/t/how-to-deny-any-file-opening-in-a-specific-folder/20488 "2022-09-21T07:53:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsharan.02](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@dsharan.02](https://forums.powershell.org/u/dsharan.02)\
**Post date:** [September 21, 2022, 7:53am UTC](https://forums.powershell.org/t/how-to-deny-any-file-opening-in-a-specific-folder/20488/1 "2022-09-21T07:53:42Z")

</div>

how to deny any kind of file opening in a specific folder( like test) in windows server 8.  
Either its a word, excel, autocad , text or any kind of file, should not get open in that particular folder and its subfolders. but users should able to copy and paste the file & folders in test folder.

Actually I do not want to open the file in test folder. User can see the content of the folder but he should not open any file of that particular folder. sub folders should open in test folder but file opening have to be denied.

i am trying to do this by Powershell script but some errors are generating.  
1st option :- Get-COMMAND “select-object ‘D:\test\*.\*’-open -deny”

2nd option:- when “D:\test\*._’ open then Get-COMMAND "select-object 'D:\test_.\* ’ -open -deny”

![1](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/5/5f718556bed1b5c66fcc7faa83dd04b90456e9c8.jpeg)

my requirement is to disable open option ( marked in circle ) in test folder , so any user can not open the file in test folder, but user can open sub folders inside the test folder.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [September 21, 2022, 8:49am UTC](https://forums.powershell.org/t/how-to-deny-any-file-opening-in-a-specific-folder/20488/2 "2022-09-21T08:49:16Z")

</div>

DS\_02,  
Welcome to the forum. 👋🏽

AFAIK there is no built in PowerShell cmdlet offering this kind of functionality. So this is actually not a PowerShell question. I’d recommend to ask this in a “Windows System” related forum.

If I remember right you would need to manipulate the setting for each individual file type. And I’m very sceptic if you can change this setting for individual folders.

Regardless of that - When you post code, sample data, console output or error messages please format it as code using the _preformatted text_ button ( **\</\>** ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

[How to format code in PowerShell.org](https://aws1.discourse-cdn.com/business5/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif) \<---- Click 👆🏽 😉

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/how-to-deny-any-file-opening-in-a-specific-folder/20488/3 "2024-05-16T20:16:38Z")

</div>

Closed on May 16, 2024, 8:16pm UTC


