OK, enumerating network computers and shares 101:
Replace "YourWorkgroup" with the name of your workgroup or domain and "remotepc" with the name of a computer you want to query.
Using commands:
Code:
:: To list network computers.
NET VIEW /DOMAIN:YourWorkgroup
:: To list shares on a computer.
NET VIEW \\remotepc
Using C/C++ code:
Use NetServerEnum() and NetShareEnum() or WNetEnumResource().
Using vbscript:
Code:
'''' Enumerate computers in a workgroup or domain.
Dim domain 'As IADsDomain, IADsContainer, IADs
Dim computer 'As IADsComputer, IADs
Set domain = GetObject("WinNT://YourWorkgroup")
domain.Filter = Array("Computer")
For Each computer In domain
strComputer = computer.Name
WScript.Echo strComputer
Next
'''' Enumerate shares on a computer using ADSI.
Dim fs 'As IADsFileService, IADsContainer, IADs
Dim share 'As IADsFileShare, IADs
strComputer = "remotepc"
Set fs = GetObject("WinNT://" & strComputer & "/lanmanserver")
For Each share In fs
Wscript.Echo share.Name
WScript.Echo share.HostComputer
WScript.Echo share.Path
Next
'''' Enumerate shares on a computer using WMI.
strComputer = "remotepc"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")
For each objShare in colShares
Wscript.Echo "AllowMaximum: " & vbTab & objShare.AllowMaximum
Wscript.Echo "Caption: " & vbTab & objShare.Caption
Wscript.Echo "MaximumAllowed: " & vbTab & objShare.MaximumAllowed
Wscript.Echo "Name: " & vbTab & objShare.Name
Wscript.Echo "Path: " & vbTab & objShare.Path
Wscript.Echo "Type: " & vbTab & objShare.Type
Next
MsgBox "End"
To execute vbscript, place it in a text file with the extension ".vbs" and double click to run. Note that the WMI method of enumerating shares will return hidden shares but requires admin access to run. I don't think the ADSI method requires admin access(assuming you have one or more accessible shares) but I don't think it will return hidden shares.
Useful ADSI link (for searchers): http://dev.coadmin.dk/Resources/ADSI...HTML/winnt.htm