IPAM will assist
you in managing IP addresses.
To let you into a secret, this utilities is fun to use, even if you
don't have a pressing need to calculate your IP address space.
Get a free evaluation copy of
Orion IPAM
Is your server running slowly? Check with SolarWinds ipMonitor
Get a free evaluation copy of ipMonitor
Contents for Ezine 75 List Shares - Out-takes
- This week's secret
- This Week's Mission - To Display
Network Shares
- Example 1 - To Map to Display Network Shares
- Example 2 - To Map to Display Network Shares
This Week's Mission - To Display Network SharesWhat this week's script will do is to display shared folders and printers. In the first example, we have to hard-code the name of the server in
the script itself. The second script not only provides an inputbox for you to interrogate different servers, but also lists the shares in one long list. The first example is easy scripting but
laboriously echoes each share in turn. It drove me mad because I had to keep clicking OK on each share's message box. The second share builds up a list of all shares then displays them all in one
long list. Start - Check the basic scripts I suggest that you start with the working scripts, then try and correct these mistakes.
Out-take 1 - To Map to Display Network Shares
Here is a simple script, which should interrogate a servers operating system, and then echo each shared folder or shared printer. Instructions for displaying a servers shares - Copy and paste the script below into notepad.
- 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 Out-Take 1.2 -
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
Learning Points for Listing SharesNote 1: Pay attention to case sensitive words.
Out-Take 2 - To Map to Display Network Shares
' ListShare.vbs Windows Logon Script ' VBScript List Shares on a Server ' Author Guy Thomas http://computerperformance.co.uk/ ' Ezine 75 Out-Take 2.3 -
May 2005 ' ----------------------------------------------------' Option Explicit
Dim objFs, objShare Dim strServer, strList
' The section sets the variables strList = "
--------------------------- " strServer = "alan"
' Creates the Input Message Box strServer = InputBox("Server to list shares: "_ ," Share List", strServer)
' Connects to the operating
system's file system set objFs = GetObject("WinNT://" _ & strServer & "/LanmanServer,FileService")
' Loops through each share For Each objShare In objFs strList = strList & vbCr &
LCase(objShare) _ & " " & vbTab & UCase(objShare.Description) Next
WScript.Echo strList
End of List Share VBScript
Learning Points for Example 2Note 1: Review the Object, Property syntax.
Answers
Out-Take 1. Should be WinNT not WINNT
Out-Take 2. You need the name property, objShare.name not objShare
Their topics and material are ideal for getting you started with VBScript. The
videos are easy to follow and you can control the pace. Try their free demo material and then see if you want to buy the full package.
See more about VB Script Training CD.
|