how do I set folder share programmatically in vb.net
Directory.CreateDirectory("C:\MyTestShare") 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)