Use the Delete method of the win32_share

Can anyone tell me how to use delete method of win32_share to stop a shared folder .Im using visual studion& using ManagementClass .It doesnt accept any parameters and i dont know how to use it .

Im using the code below to share the folder :

Dim mc As ManagementClass = New ManagementClass("win32_share")
        Dim inParams As ManagementBaseObject = mc.GetMethodParameters("Create")
        inParams("Description") = "Test"
        inParams("Name") = "Test"
        inParams("Path") = "C:\Test"
        inParams("Type") = &H0
        inParams("MaximumAllowed") = Nothing ' Set unlimited number of users connected, or specify a positive integer.
        inParams("Password") = Nothing
        inParams("Access") = Nothing ' Make Everyone has full control access.
        Dim outParams As ManagementBaseObject = mc.InvokeMethod("Create", inParams, Nothing)
AJDeveloperAsked:
Who is Participating?
 
CodeCruiserCommented:
>The Delete Win32_Share doesnt accept any parameters
That is why we are passing it "Nothing". Did you get any errors when running above?


Try code from here

http://www.codeproject.com/KB/vb/RemoteShare.aspx?display=Print
0
 
CodeCruiserCommented:
May be

mc.InvokeMethod("Create", Nothing)
0
 
CodeCruiserCommented:
Oops

mc.InvokeMethod("Delete", Nothing)
0
 
AJDeveloperAuthor Commented:
Nope ,im getting error .The Delete Win32_Share doesnt accept any parameters ,Can you post the code where it can delete the share folder which was created by the mentioned code ?
0
 
AJDeveloperAuthor Commented:
It is not using the managementclass but is working perfectly.
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.