Solved

Use the Delete method of the win32_share

Posted on 2011-02-16
5
1,095 Views
Last Modified: 2012-05-11
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)
0
Comment
Question by:AJDeveloper
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34908151
May be

mc.InvokeMethod("Create", Nothing)
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34908158
Oops

mc.InvokeMethod("Delete", Nothing)
0
 

Author Comment

by:AJDeveloper
ID: 34909768
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
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 total points
ID: 34914532
>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
 

Author Closing Comment

by:AJDeveloper
ID: 34914767
It is not using the managementclass but is working perfectly.
Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now