0

Exact opposite of this question.

I'm trying to track an intermittent issue with a software, issue that seems to be related to a folder that is kept locked for just a bit too long... once in a while.

I want to find a way to lock it myself and choose when the lock is to be released. How can I achieve that?

I know of at least one software that can lock a file, but for the next step, I need to find a way to lock an empty folder.

jmr
  • 486
  • 4
  • 5
  • Perhaps useful link: [How to Lock Folder in C#](https://stackoverflow.com/questions/4198048/how-to-lock-folder-in-c-sharp). If you have at least some programming experience you should be able to copy and paste this into visual studio and build the executable. – Bennett Yeo Aug 07 '18 at 18:07
  • @BennettYeo: Thanks. I hadn't seen that before. It'd definitely work, but I'm hoping for a lighter solution. But you make me realize that I could possibly find something in powershell. I'll have to look. – jmr Aug 07 '18 at 18:45
  • Jmr if you want a powershell script try this: [Locking the file while writing in PowerShell](https://stackoverflow.com/questions/21086051/locking-the-file-while-writing-in-powershell). It will be harder to customize than the C# script. – Bennett Yeo Aug 07 '18 at 18:47
  • @BennettYeo: Thanks again. I got it to work for locking files, but not for folders. The error is a bit strange (access denied), but given that the (working) file and (not working) folders are in the same place, I'm more suspecting that that API doesn't make sense when called on folders - especially given its name. – jmr Aug 07 '18 at 19:32
  • Duty Check: Are you running elevated? Sometimes access denied errors can be fixed if you run as admin. – Bennett Yeo Aug 07 '18 at 19:34
  • @BennettYeo: yes, I am. – jmr Aug 07 '18 at 19:50
  • Would [something like this](https://pastebin.com/iiwDJdY9) do what you want? – Bennett Yeo Aug 07 '18 at 19:59
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/81301/discussion-between-jmr-and-bennett-yeo). – jmr Aug 07 '18 at 20:07

1 Answers1

0

We can set the "Delete" and "Delete subfolders and files" permissions to "Deny" under PropertiesSecurityAdvanced.

Change the Type to “Deny” and first make sure not any other permission is selected, we can click the “Clear all” button to do that. Now only tick the “Delete subfolders and files” and “Delete“.

enter image description here

For details, we can refer this articles: https://quickfever.com/how-to-lock-folders-or-files-to-prevent-deletion-981593/

Daisy Zhou
  • 991
  • 1
  • 5
  • 4
  • Thanks. This is a similar approach to what was suggested in the chat - change the folder permissions rather than block the folder as "currently in use", but it might very well work. I'll have to try and report back. – jmr Aug 09 '18 at 02:34