Solved

Use the Delete method of the win32_share

Posted on 2011-02-16
5
1,200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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