Professional Documents
Culture Documents
Lab
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
To start simply click on the named Workstation from the device list (located on
the left hand side of the screen) and click 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
COMP230_Wk 5_Modular_Lab
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.
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.
COMP230_Wk 5_Modular_Lab
COMP230_Wk 5_Modular_Lab
2) Option 2 from the menu is handled by Case 2 in the Select Case statement.
The Case 2 code segment shows the Check System Memory routine. The
somewhat cryptic code shown below utilizes an extremely important tool called
Windows Machine Instrumentation (WMI). WMI allows you to access many
underlying objects and attributes managed by the Windows OS.
The variable strComputers value . refers to the local computer rather than a
remote computer. See where strComputer is used when you are defining
objWMIService. The ExecQuery method is used to send a query (Select *
from Win32_ComputerSystem) to the operating system.
COMP230_Wk 5_Modular_Lab
Note that the memory size is divided by 1M (1048576) so the answer can be
expressed in Mbytes instead of Bytes. The run is shown below the script code.
3) Option 3 from the menu is handled by Case 3 in the Select Case statement.
The Case 3 code segment shows the Check Operating System Version
routine. Note that this program makes use of the same objWMIService
definition as the last program.
Again we use the ExecQuery method to send a query to the Windows OS. Note,
however, that query has a diferent target (Select * from
Win32_OperatingSystem). Notice also that the ExecQuery method always
returns a collection object colOperatingSystems. An ExecQuery can return
more than one record so we need to handle the display in a For Each/Next loop.
4) Option 4 from the menu is handled by Case 4 in the Select Case statement.
The Case 4 code segment shows the Check Printers Status routine. This
COMP230_Wk 5_Modular_Lab
routine, like the last two, defines the objWMIService object in exactly the same
way. This time the W32_Printer is queried. A run of the Check Printers Status
routine is shown on the next page.
COMP230_Wk 5_Modular_Lab
with Where FreeSpace > 0. The where clause ensures we will not display the
CDROM or DVD drives. The Size and FreeSpace are divided by 1G (1073741824)
to display the sizes in Gbytes.
6) Open a Windows CLI as Administrator and run the PC_Tests.cmd Batch file
(C:\comp230\PC_Tests.cmd <Enter>). The Batch script will clear the screen and
display the PC Tests menu. After a choice is made, the PC_Tests.vbs program is
run using cscript.
7) Run all of the PC Tests and see what happens when you enter incorrect menu
choices. Is there any error-handling incorrect menu choices? Make sure that
everything is functional before you start your Task 3 modifications.
COMP230_Wk 5_Modular_Lab
COMP230_Wk 5_Modular_Lab
2) Before you do a final save of Mod1_PCTests.vbs and close the script, you
need to do one more modification. You need to add error-handling in the VBScript
program for incorrect menu choices in the Batch script. Add a default Case (case
Else) in the Select Case statement between the Case 5 subroutine call and
the End Select statement. The error-handling routine Beeps the speaker twice
(sending an ASCII code 7 to screen two times) and displays an appropriate error
message.
3) Open the Windows CLI (Command Prompt) in the C:\comp230 directory and
run the Mod1_PCTests.cmd Batch script which will call the Mod1_PCTests.vbs
program. In your run, show error-handling and successful execution of all five PC
Tests.
Note: Please edit your Run for each menu option so that the Menu is
shown only once for option 1 and thereafter just show the selected
option choice and the subroutine output. To save space in the labreport document, please edit your run to show only the first Printer and
the first Hard Drive. You must also show error-handling in your Run. A
Sample Edited Run is shown at the end of the lab.
Copy your Mod1_PCTests.vbs program and your complete edited Run in your lab-report
document in the specified textboxes.
6) The only other change we need to make Mod2_PCTests.vbs is one that will
give us access to the library string. That line is shown below. This should be the
last line before the beginning of the Select Case statement. From the previous
step, we know that all of the PCT_Library.vbs file content has been loaded into
the string variable librarySubs. The command ExecuteGlobal librarySubs on
line 11 gives us access to all of the procedures and functions contained within
that string as if they were directly implemented within the Mod2_PCTests.vbs
script.
COMP230_Wk 5_Modular_Lab
10
we want to use. The final code for Mod2_PCTest.vbs (minus the programmer
header) is shown below.
2) Open the Windows CLI as Administrator and run the Modular PC Tests script
Mod2_PCTests.vbs from the Mod2_PCTests.cmd Batch scripts.
Note: If you receive an error message on the ExecuteGlobal
librarySubs line, you need to check the PCT_Library.vbs file for errors.
3) In your run, show error-handling and successful execution of all five PC Tests.
Note: Please edit your Run for each menu option so that the Menu is shown only
once for option 1 and thereafter just show the selected option choice and the
COMP230_Wk 5_Modular_Lab
11
subroutine output. To save space in the lab-report document, please edit your
run to show only the first Printer and the first Hard Drive. You must also show
error-handling in your Run. A Sample Edited Run is shown at the end of the lab.
Copy your Mod2_PCTests.vbs program and your complete edited Run in your lab-report
document in the specified textboxes.
COMP230_Wk 5_Modular_Lab
12
COMP230_Wk 5_Modular_Lab
13