Student Name
Caleb Cunningham
Class
Date
VBScript Modular Lab Report
Copy your Mod1_PCTests.vbs program from NotePad++ and paste it into the space provided below. Any portion of the script that will not fit should be continued in the textbox on the next page.
' Menu Driven Computer / Network Tests ' This VBScript program is run using the PC_Tests.cmd Batch Script Set args = WScript.Arguments WScript.Echo vbCrLf Select Case args.Item(0) Case "1" Call System_Information Case "2" Call System_Memory_Size Case "3" Call OS_Version Case "4" Call Printer_Status case "5" Call Logical_HDD_Information End Select Sub System_Information Set wshShell = Wscript.CreateObject("WScript.Shell") WScript.Echo "The computer name is ............ " & _ WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%") WScript.Echo "The Num of CPUs is .............. " & _ WshShell.ExpandEnvironmentStrings("%NUMBER_OF_PROCESSORS%") WScript.Echo "The Processor Architecture is ... " & _ WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") Next End Sub Sub System_Memory_Size strComputer = "." Set objWMIService = GetObject _ ("winmgmts:\\" & strComputer & "\root\CIMV2") Set colComputer = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each objComputer in colComputer intRamMB = int((objComputer.TotalPhysicalMemory) /1048576)+1 Wscript.Echo "System Name ...... " & objComputer.Name _ & vbCrLf & "Total RAM ........ " & intRamMB & " MBytes." End Sub Sub OS_Version Set wshShell = Wscript.CreateObject("WScript.Shell") strComputer = "." Set objWMIService = GetObject _ ("winmgmts:\\" & strComputer & "\root\CIMV2") Set colOperatingSystems = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") WScript.Echo "The Operating System Detected is Shown Below:" & vbCrLf For Each objOperatingSystem in colOperatingSystems WScript.Echo objOperatingSystem.Caption & "Version: " & _ objOperatingSystem.Version End Sub Sub Printer_Status Set wshShell = Wscript.CreateObject("WScript.Shell") strComputer ="." intPrinters = 1
COMP230_W5_Modular_Report.docx
Revision Date: 1204
Copy your PCT_Library.vbs script from NotePad++ and paste it into the space provided below. Reduce the font size if required to make the script code fit in the textbox.
Set args = WScript.Arguments WScript.Echo vbCrLf Set fso = CreateObject("Scripting.FileSystemObject") Set vbsLib = fso.OpenTextFile("C:\Scripts\PCT_Library.vbs",1,False) LibrarySubs = vbsLib.ReadAll vbsLib.Close Set vbsLib=Nothing Set fso=Nothing ExecuteGlobal librarySubs Select Case args.Item(0) Case "1" Call System_Information Case "2" Call System_Memory_Size Case "3" Call OS_Version Case "4" Call Printer_Status case "5" Call Logical_HDD_Information case Else WScript.Echo (chr(7) & chr(7) & "Error, Correct Values are 1..5 or X!!") End Select
COMP230_W5_Modular_Report.docx
Revision Date: 1204
Capture the Mod2_PCTests.vbs Run from the console window and copy it into the space provided below. Display the menu only once with an error-handling message. If it will not fit, use the next page for the rest of your Run. As noted in the lab assignment, display only the first Printer and the first Hard drive to save space.
Computer System Analysis
[1] [2] [3] [4] [5] [x]
Check System Information Check System Memory Check Operating System Version Check Printers Status Check Logical Drive Information Exit Program"
Enter the Number of your Choice .... 6 Error, Correct Values are 1..5 or X!! Press any key to continue . . . The computer name is ............ Caleb_PC The Num of CPUs is .............. 8 The Processor Architecture is ... Intel64
System Name ...... Lenovo-PC Total RAM ........ 8064 MBytes.
The Operating System Detected is Shown Below: Microsoft Windows 7 Ultimate Version: 6.1.7601
======================================== Drive Letter ......... C: Description .......... Local Fixed Disk Volume Name .......... Drive Type ........... 3 Media Type ........... 12 VolumeSerialNumber ... 08DB9411 Size ................. 512 GB Free Space ........... 228 GB
COMP230_W5_Modular_Report.docx
Revision Date: 1204
Capture the continuation of the Mod2_PCTests.vbs Run from the console window and copy it into the space provided below:
COMP230_W5_Modular_Report.docx
Revision Date: 1204