I have Client-Server environment and developed a project for Client-Server.

I need to share a folder of my Server machine programmatically using VB.NET

Please help me.

Was it helpful?


Here's one example which shows the concept using ManagmentClass. It's C# but easily convertible to VB.NET:


Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams.Item("Description") = "My Files Share"
inParams.Item("Name") = "My Files Share"
inParams.Item("Path") = "C:\MyTestShare"
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


I have code that looks similar to this which works on vista and win2k3 machines, but when i try it on Windows server 2008 R2 (with recent updates) it fails with an "access denied" error. I've tried your exact code above and the same result. I am an Admin on the box and I have tried disabling UAC but without any effect.

(i know this isn't an answer, I have no power to comment)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow