Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Shared Folders with VBScript

Status
Not open for further replies.

ndisdabest

Programmer
Dec 17, 2004
4
US
I'm wondering if anyone knows how to script something that looks for, finds, and counts the shared folders that exist on any one PC.

This is an urgent issue... if anyone has any suggestions, please respond ASAP!

Thanks!
 
when you say 'issue' what do you mean???

does this not work?

Set FileService = GetObject("WinNT://" & ComputerName & "/LanmanServer")
For Each FileShare In FileService
Wscript.Echo FileShare.Name
Next

or perhaps

cmd /c net share > c:\results.txt
 
By urgent "issue," I mean that it is a script that needs to be written fairly soon.

If I understand it correctly, the script posted above will look on any one computer for all shared folders and return the names of those folders?
 
i dont know if it will work on any computer. i havent even tried it on my machine.
give it a whirl
 
If you want a count you might be stuck with

intC = 0
Set FileService = GetObject("WinNT://" & ComputerName & "/LanmanServer")
For Each FileShare In FileService
intC = intC + 1
Wscript.Echo FileShare.Name
Next
Wscript.Echo "number=" & intC

or you might get away with
FileService.Count

please not that this will not list and count the ipc$, admin$ or c$ etc ie the system hidden shares...but it will list the user created hidden shares.

you can still bind to the system hidden shares though
 
Alright, I'll give it a shot. Thanks for your help.

If anyone else has any suggestions, please post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top