Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

List shares

Hi,

If I have a server name, how do I get a list of shares on that server?
A code snippet would be appreciated.

Thanks...
0
bukko
Asked:
bukko
1 Solution
 
DhaestCommented:
You could try something like this, remember to have imports System.Management

Private Sub EnumShares(ByVal Machine As String)
        'Local Shares
        Try
            Dim scope As String = ("\\" & Machine & "\root\cimv2")
            Dim SharesClass As ManagementClass = New ManagementClass(scope, "Win32_Share", Nothing)
            Dim Shares As System.Management.ManagementObjectCollection = SharesClass.GetInstances()
            Dim Share As System.Management.ManagementObject

            For Each Share In Shares
                MessageBox.Show("Description: " & Share("Description"))
                MessageBox.Show("Name: " & Share("Name"))
                MessageBox.Show("Path: " & Share("Path"))
            Next
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
End Sub

Although you'd probable only want those shares that have a type of 0

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21057476.html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now