Escolar Documentos
Profissional Documentos
Cultura Documentos
Objectives
In this lab, students will complete the following objectives.
Lab Diagram
During your session you will have access to the following lab configuration.
Vlab-PC1
Vlab-PC2
To start simply click on the named Workstation from the device list (located on
the left-hand side of the screen) and click the Power on in the tools bar. In some
cases the devices may power on automatically.
During the boot up process an activity indicator will be displayed in the name
tab.
BlackPowered Of
OrangeWorking on your request
GreenReady to access
If the remote console is not displayed automatically in the main window (or
popup) click the Connect icon located in the tools bar to start your session.
COMP230_Wk3_Network_Shares_Lab.docx1
If the remote console does not appear please try the following option.
Switch between the HTML 5 and Java client versions in the tools bar.
In the event this does not resolve your connectivity problems, please visit our
Help/Support pages for additional resolution options.
2) 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:\comp230 folder. Make sure to change the type to All types(*.*) as shown
below.
COMP230_Wk3_Network_Shares_Lab.docx2
4) 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.
Note: The first argument is the file(s) to be copied and second argument (after
the ,) is the destination folder.
6) Skip several lines and enter the following statement. The WScript.Echo
statement simply outputs a new line and announces the end of the program.
7) Save your program (<Ctrl>S). Open a Command Window and use cscript to
test your program. Make sure you are in the comp230 directory when you type
the command. We want to make sure that the directory was created and the files
were copied.
cscript NetShareServer.vbs
8) Your program should run without errors and display the message End of
Program. Now To verify that the program successfully created the C:\Public
directory and populated it with some files type the command:
dir C:\Public
You should see a list of files there.
COMP230_Wk3_Network_Shares_Lab.docx3
9) If you run the program a second time it will generate an error message: File
already exists. We cannot create the c:\public folder if it already exists. We can
use a selection structure to resolve this problem. The psuedocode of what we
want to do and the code is below.
Pseudocode
If the c:\public folder exists
Remove it
Tell me what you did
End if
vbscript
If fso.folderexists(C:\public) then
fso.deletefolder(C:\public)
Wscript.echo Public folder
deleted
End if
Return to Notepad++ and add this new vbscript code BEFORE the statement.
fso.CreateFolder(C:\public)
Save and return to the command window to test that you can now run the
program multiple times without error.
10) Now lets view the current network shares (if any). Skip a line after the
fso.CopyFile line and enter the following program lines.
COMP230_Wk3_Network_Shares_Lab.docx4
computer. From the Windows CLI, the NET SHARE command would display the
same information.
Note: The For Each Next loop is a special For loop used to access the elements
or components in an array. The fileServ object contains an array name( ) that
contains all the current network shares fileServ.name(0) .. fileServ.name(n)
where n is the last index in the array.
Save and test your program. It should display any current network shares.
11) Now lets create a new network share. Within a VBScript program, you need
to use the LanmanServer,FileService object which we named fileServ to
create a new network share. Enter the following lines AFTER the for/next loop
above (before End of Program message) to share the C:\Public folder with
the share name PublicData. Note where the share name and folder path go in
the following commands. MaxUserCount sets the maximum simultaneous
connections allowed for this share.
12) After we have created the new share, we want to see if the new PublicData
share has been added. Type the following code to view the current shares again.
The WScript.Echo vbCrLf command displays a blank line.
13) Save your program (<Ctrl>S). Run your program from the command window
using
cscript NetShareServer.vbs.
You should get a run in the console windows similar to the one below. Note that
the current shares may be diferent on various systems. The important thing is to
verify that the new network share PublicData has been created and displays
ONLY under New Network Shares.
COMP230_Wk3_Network_Shares_Lab.docx5
Note: If you have errors and need to re-run the program at this point in the
development, you may see the PublicData share in both the Current and New
Shares because the share may still be valid from your earlier run.
14) Just above the End of Program message, add the following code. The
WScript.Sleep(60000) will pause the script for 60 seconds (or 60,000
milliseconds). The fileServ.Delete and fso.DeleteFolder methods will delete
the Network Share and delete the C:\Public folder and the files it contains.
15) Save your program (<Ctrl>S) and return to command window to test your
program. You should get output similar to the one previously shown. Wait until
you see the End of Program after the 60-second delay.
Copy and paste your NetworkShareServer program sourcecode from NotePad++ and your
Run from the NotePad++ Console or the Windows CLI RUN into the spaces provided in
your lab-report document.
COMP230_Wk3_Network_Shares_Lab.docx6
Leave the devices you have powered on in their current state and proceed to the
next task.
3) Now we will map the shared folder to X: and display the files from PC2. You will
need to create Scripting. FileSystemObject called fso to display the files in
the mapped drive. The WScript.Network object networkObj actually does the
mapping and unmapping of the network share to drive X: Add the following lines.
4) Complete the program with VBScript code that will display the contents of the
mapped drive X:, unmap the mapped drive X:, and end the program with the
message: End of Program as shown below.
COMP230_Wk3_Network_Shares_Lab.docx7
5) Check your NetShareClient.vbs program for errors and save it using <Ctrl>S.
In order to test it we need to run the client program first, then the server. Open
the command window to prepare for the testing described in the next task.
COMP230_Wk3_Network_Shares_Lab.docx8
If you do not get the output shown above for the NetShareClient.vbs program,
correct any errors and re-save your program. Run the NetShareServer program
again on Vlab-PC1 and run the corrected NetShareClient program on VlabPC2.
Copy and paste your NetShareClient program sourcecode from NotePad++ and your
NotePad++ console run (or Windows CLI run) into the spaces provided in your labreport document. Submit your completed lab-report document to the iLab Dropbox for
this week.
COMP230_Wk3_Network_Shares_Lab.docx9