I use this code to share folder:
Public Sub Share()
Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams("Description") = "My Description"
inParams("Name") = "Share Name"
inParams("Path") = "D:\Folder"
inParams("Type") = &H0
Dim outParams As ManagementBaseObject = managementClass.InvokeMethod("Create", inParams, Nothing)
If Convert.ToUInt32(outParams.Properties("ReturnValue").Value) <> 0 Then MessageBox.Show("Unable to share directory.")
MessageBox.Show("Shared folder successfully!")
End
Sub
Now what I want is to define user that can access to this folder through network? How I can do that?
Thanks!
Shared folder permissions are used to restrict access to a folder or file that is shared over a network. Folder sharing is normally used to grant remote users access to files and folders over a network.
Windows provides two sets of permissions to restrict access to files and folders: NTFS permissions and share permissions.
This blog entry explains how to set up permissions for a share:
http://blogs.msdn.com/helloworld/archive/2008/06/06/programmatically-configuring-permissions-on-a-share-in-c.aspx
The code is in C#, so it not be a problem to port it to VB.
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