This script will interrogate the operating system and then echo each share to a message box. There is one pre-requisite. Naturally, you must have a shared folder or printer on the machine that you run the script.
Instructions for displaying a servers shares
- Copy and paste the script below into notepad.
- Change the name of GuyServer on Line 11. Set the strServer to the name of your computer.
- Save the file with a .vbs extension e.g. ListShare .vbs.
- Double click the script, then read the names of the shares in the message box.
-
' ListShare.vbs Windows Logon Script
' VBScript List Shares on a Server
' Author Guy Thomas http://computerperformance.co.uk/
' Ezine 75 Version 1.3 - May 2005
' ----------------------------------------------------'
Option Explicit
Dim objFs, objShare
Dim strServer
' The section sets the variables
strServer = "GuyServer"
' Connects to the operating system's file system
set objFs = GetObject("WinNT://" _
& strServer & "/LanmanServer,FileService")
' Loops through each share
For Each objShare In objFs
WScript.Echo objShare.name
Next
End of List Share VBScript