Vbscript Network Shares Lab

Topics: Microsoft Windows, For loop, File system Pages: 6 (1575 words) Published: March 24, 2013
VBScript Network Shares Lab


In this lab, students will complete the following objectives. * Create a VBScript Program using NotePad++.
* Use WScript.Shell object and its methods.
* Use Scripting.FileSystemObject and its methods.
* Use LanmanServer,FileService objects and its methods.
* Use WScript.Network object and its methods.

Element K Network Connections

For this lab, we will need to connect to vlab-PC1 and vlab-PC2. The computer vlab-PC1 is the computer on the left side while vlab-PC2 is on the right. If you leave the cursor on the PC icon for a few seconds, a tool-tip message will appear indicating the hostname of the PC. Open vlab-PC1 and login as Administrator with the password password. Return to the network and open vlab-PC2 and login as Administrator with the password password.

Note: All captures must be text only—DO NOT capture the NotePad++ application window or the command prompt window. Use copy and paste of text only.

Task 1: NetShareServer.vbs Program on vlab-PC1

* On vlab-PC1, open NotePad++ and from the File menu, select New.

* Create a Programmer Header that includes the name of your VBScript file, your name, the date, the class, and the name of your professor. Each of these VBScript comment lines begin with a (‘) character.

* From the File menu, select Save. Save your program as NetShareServer.vbs in the C:\Scripts folder as shown below.

* Define the Scripting.FileSystemObject fso that provides control of local folders and files. The “WinNT://hostname/LanmanServer,FileService object fileServ allows us to create and manage network shares similar to the NET SHARE commands we discussed last week.

Note: When you create the fileServ object, the hostname value vlab-PC1 must match the hostname of the computer acting as the server. If you don’t know your Windows hostname, open a Windows CLI and execute the hostname command.

Task 2: Create a Folder and Copy Files to the New Folder

* Use the fso.CreateFolder( ) to create the folder C:\Public. The path and name of the folder to be created is place inside the parentheses and delimited with double quotes.

* Use the fso.CopyFile method to copy all files in the C:\Windows\Cursors\ folder that start with the letter w to the C:\Public folder. There are no parentheses used for this method. The syntax for this method is

Note: The first argument is the file/s to be copied and second argument (after the ,) is the destination folder.

* Skip several lines and enter the following statements. The WScript.Echo statement simply outputs a new line and announces the end of the program.

* Save your program (S). Press the function key and enter: cscript NetShareServer.vbs. Click OK to execute your program.

* Below is the run of the program. It should run without errors although it does not produce any output. Check to see if the program successfully created the C:\Public directory and copied the files from the C:\Windows directory by clicking in the NotePad++ console window and entering the command: dir C:\Public as shown below. You could also open the Windows CLI and execute the same command to test your script.

* Go to the command line or Windows Explorer to verify that C:\Public folder has been created and populated with some files. If you have any problems with the RUN, delete the C:\Public folder if it exists in Windows Explorer and re-run the script from the Windows CLI using cscript. Check your VBScript program for errors, make the needed changes, delete the C:\Public folder if it exists, and run the program again.

Task 3: Display Current Network Shares and Create New Share

* Skip a line after the fso.CopyFile line and enter the following program lines.

* WScript.Echo displays a message to the console windows or desktop. The For Each Next loop is used to display all of the current network shares on the local computer. From the...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • 310 network lab 3 Essay
  • Essay on VBScript Program Code: Lab
  • Vbscript Ip File Lab Essay
  • ?VBScript Modular Programming Essay
  • computer networks lab Essay
  • Lab assessment Essay
  • Essay about network topology
  • Share Essay

Become a StudyMode Member

Sign Up - It's Free