Is there a way to open the Advanced Security Settings dialog for a directory/file programmatically? This is the dialog I want to open:
You open it by clicking the Advanced button on the Security properties dialog for the directory/file.
There is this answer that shows how to open the Security properties tab using ShellExecuteEx
, so perhaps there are different parameters that can be used to open the Advanced Security Settings dialog directly, but I don't know where to find documentation (or where to look in the registry) for the verbs/parameters supported.
There is also the EditSecurityAdvanced
API, but it looks like that requires implementing the functionality to get/set the ACL instead of using the functionality built in to the Windows shell.
I'm working in VB.NET, but can translate C# or Windows API calls as needed, and pointers for how to do my own research would also be appreciated.
I couldn't find a direct way of opening it either. Using automation like the commentator Visual Vincent suggested isn't too hard. Don't forget to add references to the assemblies and import System.Windows.Automation
Then this code should press the Advanced
button for you. This way still creates the main properties dialog though.
Dim FileName As String = "The file name you are viewing the properties of"
Dim AE As AutomationElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, New PropertyCondition(AutomationElement.NameProperty, FileName + " Properties"))
Dim Advancedbtn = AE.FindFirst(TreeScope.Element Or TreeScope.Descendants, New PropertyCondition(AutomationElement.NameProperty, "Advanced"))
TryCast(Advancedbtn.GetCurrentPattern(InvokePattern.Pattern), InvokePattern).Invoke()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With