Contents for Ezine 75 List Shares – Out-takesThis 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 SharesHere 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
‘ ListShare.vbs Windows Logon Script ‘ The section sets the variables ‘ Connects to the operating system’s file system ‘ Loops through each share End of List Share VBScript Learning Points for Listing SharesNote 1: Pay attention to case sensitive commands Out-Take 2 – To Map to Display Network Shares‘ ListShare.vbs Windows Logon Script Dim objFs, objShare ‘ The section sets the variables ‘ Creates the Input Message Box ‘ Connects to the operating system’s file system ‘ Loops through each share WScript.Echo strList End of List Share VBScript
Learning Points for Example 2Note 1: Review the Object, Property syntax. AnswersOut-Take 1. Should be WinNT not WINNT Out-Take 2. You need the name property, objShare.name not objShare |
◦ |