VBScript Network Stocks and shares Lab Targets In this lab, students will complete the following objectives. 5. Create a VBScript Program employing NotePad++. 5. Use WScript.
Shell subject and its methods. * Employ Scripting. FileSystemObject and its methods. * Use LanmanServer, FileService objects as well as methods. 5. Use WScript. Network thing and its strategies. Element E Network Connections For this laboratory, we will have to connect to vlab-PC1 and vlab-PC2. The computer vlab-PC1 is the computer system on the left side while vlab-PC2 can be on the right.
If you keep the cursor on the COMPUTER icon for some seconds, a tool-tip concept will appear suggesting the hostname of the PERSONAL COMPUTER. Open vlab-PC1 and get access as Officer with the security password password. Go back to the network and open up vlab-PC2 and login since Administrator while using password password. Note: Every captures must be text only”DO NOT record the NotePad++ application windows or the control prompt windowpane. Use copy and paste of text only. Activity 1: NetShareServer. vbs System on vlab-PC1 * Upon vlab-PC1, wide open NotePad++ and from the File menu, choose New. Make a Programmer Header that includes the name of your VBScript document, your name, the date, the students, and the brand of your professor. Each of these VBScript comment lines begin with a (‘) figure. * From the File menu, select Preserve. Save your software as NetShareServer. vbs inside the C: Intrigue folder because shown below. * Define the Scripting. FileSystemObject fso that provides control of local folders and data. The “WinNT: //hostname/LanmanServer, FileService object fileServ allows us to create and control network stocks similar to the NET SHARE instructions we mentioned last week.
Notice: When you generate the fileServ object, the hostname worth vlab-PC1 must match the hostname with the computer performing as the server. Understand what know the Windows hostname, open a Windows CLI and do the hostname command. Process 2: Make a Folder and Copy Data to the New Folder 2. Use the fso. CreateFolder( ) to create the folder C: Public. The path and identity of the folder to be made is place inside the parentheses and delimited with dual quotes. 5. Use the fso. CopyFile method to copy most files in the C: WindowsCursors folder that start with the letter t to the C: Public folder.
There are no parentheses intended for this method. The syntax just for this method is Notice: The first argument may be the file/s being copied and second disagreement (after the, ) is definitely the destination folder. * Neglect several lines and enter the following transactions. The WScript. Echo affirmation simply outputs a new series and announces the end in the program. * Save your program (S). Press the function key and enter: cscript NetShareServer. vbs. Click ALRIGHT to execute your software. * Under is the work of the plan. It should manage without errors although it will not produce virtually any output.
Check to see if the program successfully created the C: Community directory and copied the files through the C: Windows directory simply by clicking in the NotePad++ system window and entering the command: euch C: Community as displayed below. You might also open the Windows CLI and perform the same command to test your script. 5. Go to the command line or perhaps Windows Manager to validate that C: Public folder has been produced and populated with some data files. If you have any problems with the RUN, delete the C: Public file if it is available in Glass windows Explorer and re-run the script from your Windows CLI using cscript.
Check your VBScript program to get errors, associated with needed adjustments, delete the C: General public folder if this exists, and run this software again. Task 3: Screen Current Network Shares and Create Fresh Share * Skip a line following the fso. CopyFile line and enter the following program lines. * WScript. Echo shows a message to the console home windows or computer system. The For each and every Next loop is used to show all of the current network stocks and shares on the local computer. In the Windows CLI, the NET REVEAL command could display similar information. Notice: The For each and every Next cycle is a exceptional For cycle used to get the factors or elements in an array.
The fileServ object includes an array name( ) which contains all the current network stocks fileServ. name(0).. fileServ. name(n) where n is the last index in the array. * Within a VBScript program, you may use the “LanmanServer, FileService object to create a new network share. Enter the subsequent lines to share the “C: Public file with the reveal name PublicData. Note in which the share name and file path use the following orders. MaxUserCount units the maximum coexisting connections allowed for this share. After we certainly have created the fresh share, we want see if the newest PublicData discuss has been added.
Type the following code to watch the current stocks again. The WScript. Indicate vbCrLf command word displays a blank line. 5. Save your plan (S). Press the function key and enter: cscript NetShareServer. vbs. Click FINE to perform your program. You should get a blunder message while shown beneath because the folder you are attempting to create at this point already is present. * 5. Add a fresh line only above the fso. CreateFolder( ) line with this statement: On Error Resume Subsequent. This affirmation will disregard non-critical mistakes and allow the program to continue. 2. * Save your valuable program (S) and press the function key and enter: cscript NetShareServer. vbs. Click FINE to perform your program. You should get a run inside the console home windows similar to the one particular below. Verify that the fresh network reveal “PublicData continues to be created. Note: If you have errors and ought to re-run this program at this point inside the development, you could see the PublicData share in both the Current and Fresh Shares because the share may well still be valid from your before run. Process 4: Put Time Postpone, Delete PublicData Share, and Delete C: Public Just above the End of Program message, add the following code. The WScript. Sleep(60000) will pause the script pertaining to 60 seconds (or 60, 000 milliseconds). The fileServ. Delete and fso. DeleteFolder strategies will delete the Network Share and delete the C: General public folder as well as the files it has. * Keep your program (S) and press the function key and enter: cscript NetShareServer. vbs. Click FINE to execute your software. You should get a run in the NotePad++ system window like the one proven on the up coming page. Delay until you see the conclusion of Plan after the 60-second delay.
Copy and paste your NetworkShareServer program sourcecode from NotePad++ and your Operate from the NotePad++ Console or perhaps the Windows CLI RUN into the spaces supplied in your lab-report document. | Task five: NetShareClient. vbs Program in vlab-PC2 2. Leave vlab-PC1 open and return to the Network picture and select vlab-PC2. If it isn’t labeled, it can be the computer around the right. 2. Once the vlab-PC2 computer unwraps, log in since Administrator using a password of password. Chute the two computer windows, so you can go easier from one computer system to the other as demonstrated below. Open up NotePad++ in vlab_PC2 and create a Coder Header that features the identity of your VBScript file, a message, the day, the class, as well as the name of your professor. Each of these VBScript comment lines begin with a (‘) character. Save your program while NetShareClient. vbs. Task 6: Map the Shared File to X: and Display Files 2. You will need to make Scripting, FileSystemObject called fso to display the files inside the mapped travel. The WScript. Network thing networkObj truly does the umschlüsselung and unmapping of the network share drive an automobile X:. The UNC note network discuss we want to get is \vlab-PC1PublicData. Keep in mind that the network share PublicData may be anywhere on the network and it is not typically a local reveal. The networkObj. MapNetworkDrive method is used to map the network share on vlab-PC1 to X: drive on vlab-PC2. The Set folder = fso. GetFolder(“X: ) provides an impressive folder target for the mapped X: drive. 2. The line Established files sama dengan folder. Documents creates documents collection thing that contains all the files in the X: file. The For Each loop sequences through the products in the files collection object and displays those documents.
Type in the code shown on the next page. 5. Save your program (S) and the remaining VBScript code which will display the contents of the mapped travel X:, unmap the mapped drive Back button: and end the program with the message: End of Plan. * Check your NetShareClient. vbs program to get errors and save this using S i9000. Task 7: Final Operate of NetShareServer and NetShareClient * Go back to vlab-PC1 and start the NetShareServer. vbs program running with. As soon as the vlab-PC1 NetShareServer. vbs program is definitely running, quickly return to vlab-PC2 and start the NetShareClient. vbs program with.
Remember, you only have one minute after you have started out the NetShareServer program to successfully operate the NetShareClient program. 5. If you do not get the output proven above, for the NetShareClient. vbs system. Correct any errors and re-save your program. Run the NetShareServer program once again on vlab-PC1 and operate the fixed NetShareClient plan on vlab-PC2. Copy and paste the NetShareClient plan sourcecode coming from NotePad++ along with your NotePad++ gaming system run (or Windows CLI run) into the spaces supplied in your lab-report document. Fill in your accomplished lab-report document to the iLab Dropbox in this week. |