Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27513

Adding Share Permissions (NOT NTFS)

$
0
0
Hi All,

Having another small issue. I'm wanting to add Share Permissions to a folder without removing the existing permissions and without using PowerShell or Net API is there a way of doing this??

I am able to create a share in VB.net and I'm also able to add the NTFS Permissions but not able to create the share permissions.

I've looked into the Win32_Share.GetAccessMask but I'm not sure if that's what I'm needing or how to use it.

For creating a share I'm using the following code;

Code:

  Dim managementClass As New ManagementClass("Win32_Share")
        Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
        Try
            inParams.Item("Description") = "My Files Share"
            inParams.Item("Name") = "My Files Share"
            inParams.Item("Path") = "C:\Test"
            inParams.Item("Type") = 0
            If (DirectCast(managementClass.InvokeMethod("Create", inParams, Nothing).Properties.Item("ReturnValue").Value, UInt32) <> 0) Then
                Throw New Exception("Unable to share directory.")
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Thanks

Swain90

Viewing all articles
Browse latest Browse all 27513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>