0

I want to get all the computers in my network and all the shared folders in it(Should work in both domain and workgroup). I was able to get all the computers in the network using below code

Dim ipproperties As NetworkInformation.IPGlobalProperties = NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()
Dim domain As String = ipproperties.DomainName

Dim domainEntry As DirectoryEntry = New DirectoryEntry("WinNT://" + domain)
domainEntry.Children.SchemaFilter.Add("computer")

For Each computer As DirectoryEntry In domainEntry.Children
    ListBox1.Items.Add(computer.Name)
Next

But now i want to get shared folders of each computer. So i used this code using DirectoryEntry. But it gave error like "The group name could not be found" for a network computer. So what is the reason I am getting error. Or is there any other method to get shared folders of computers which are in my network.(I don't want to use WMI solutions)

IT researcher
  • 3,274
  • 17
  • 79
  • 143

1 Answers1

0

You could use WMI's Win32_Share: Take a look at the example here (you'll need to

  1. replace Win32_LogicalDisk with Win32_Share
  2. pass extra parameters to the ManagementObjectSearcher, as in the example here to specify a different computer.
Richard
  • 106,783
  • 21
  • 203
  • 265
  • Is there any solution without using WMI? As i mentioned in question i wanted a solution which does not use WMI. – IT researcher Nov 20 '14 at 11:04
  • @ITresearcher Sorry missed that, but WMI is the best option here, so unless you can explain why you don't want to use WMI the answer will remain: use WMI even if you don't like it. – Richard Nov 20 '14 at 12:06
  • Becasuse WMI may be disabled in some systems and also permission issues. – IT researcher Nov 20 '14 at 12:25
  • 1
    @ITresearcher disabling WMI on current WIndows will break lots of things (so a realistic blocker unless you know the environment is sufficiently odd). WMI could be blocked in the firewall, or you could lack permissions, but that will apply to another remoting.... and you need to remote in to get this information. – Richard Nov 20 '14 at 12:55