Click here to Skip to main content
15,913,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I remove the network share name from command line.The Syntax is 'net share ShareName /delete'
How will i remove network share name from local computer through coding??

Please help me....
Posted

1 solution

You could use Process.Start to run the command line...
But, this should work as well:
VB
Private Shared Function DeleteShare(shareName As String) As Integer
    Using o As New ManagementObject("root\cimv2", "Win32_Share.Name='" & shareName & "'", Nothing)
        Dim mbo As ManagementBaseObject = o.InvokeMethod("delete", Nothing, Nothing)
        Return CInt(mbo.Properties("ReturnValue").Value)
    End Using
End Function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900