0% found this document useful (0 votes)
16 views12 pages

DocMerit Comp 230 Week 5 Ilab Report Vbscript Modular Lab Report

The document is a VBScript Modular Lab Report for COMP 230, authored by Noemi Matos, detailing a menu-driven program for computer and network tests. It includes various subroutines to gather system information, memory size, operating system version, printer status, and logical hard disk information. The report emphasizes the use of VBScript to automate these tasks and provides code snippets for implementation.

Uploaded by

maxxymakau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views12 pages

DocMerit Comp 230 Week 5 Ilab Report Vbscript Modular Lab Report

The document is a VBScript Modular Lab Report for COMP 230, authored by Noemi Matos, detailing a menu-driven program for computer and network tests. It includes various subroutines to gather system information, memory size, operating system version, printer status, and logical hard disk information. The report emphasizes the use of VBScript to automate these tasks and provides code snippets for implementation.

Uploaded by

maxxymakau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

COMP 230 Week 5 iLab report

(VBScript Modular Lab Report)

written by
realer

Did you know a seller earn


an average of $450 per month
selling their study notes
on DocMerit

Scan the QR-code and learn how you can also turn your class
notes, study guides into real cash today.

DocMerit.com - The Best Study Notes

Uploaded by: realer on DocMerit. Distribution of this document is illegal


Student NOEMI MATOS Class COMP230 Dat 01-JUN-
Name e 16

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.

'Noemi Matos
'01-June-2016
'Week 5 iLab
'COMP230 - Prof. Sasha Perez
' 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 Printers_Status
Case "5"
Call Logical_HDD_Information
Case Else
WScript.Echo chr(7) & chr(7) & "Error, Choices are 1..5 or x!!!"
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%")
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."
next
End Sub
Sub OS_Version
strComputer = "."

COMP230_Wk5_Modular_Report.docx 1 Revision Date: 1213


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
next
End Sub
Sub Printers_Status
strComputer ="."
intPrinters = 1
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_Printer")
WScript.Sleep(1000)
For Each objItem In colItems
WScript.Echo _
"Printer: " & objItem.DeviceID & vbCrLf & _
"===============================================" & vbCrLf & _
"Driver Name ............. " & objItem.DriverName & vbCrLf & _
"Port Name ............... " & objItem.PortName & vbCrLf & _
"Printer State ........... " & objItem.PrinterState & vbCrLf & _
"Printer Status .......... " & objItem.PrinterStatus & vbCrLf & _
"Print Processor ......... " & objItem.PrintProcessor & vbCrLf & _
"Spool Enabled ........... " & objItem.SpoolEnabled & vbCrLf & _
"Shared .................. " & objItem.Shared & vbCrLf & _
"ShareName ............... " & objItem.ShareName & vbCrLf & _
"Horizontal Res .......... " & objItem.HorizontalResolution & vbCrLf & _
"Vertical Res ............ " & objItem.VerticalResolution & vbCrLf
intPrinters = intPrinters + 1
next
End Sub
Sub Logical_HDD_Information
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where FreeSpace > 0")
For Each objItem in colItems
WScript.Echo vbCrLf & _
"========================================" & vbCrLf & _
"Drive Letter ......... " & objItem.Name & vbCrLf & _
"Description .......... " & objItem.Description & vbCrLf & _
"Volume Name .......... " & objItem.VolumeName & vbCrLf & _
"Drive Type ........... " & objItem.DriveType & vbCrLf & _
"Media Type ........... " & objItem.MediaType & vbCrLf & _
"VolumeSerialNumber ... " & objItem.VolumeSerialNumber & vbCrLf & _
"Size ................. " & Int(objItem.Size /1073741824) & " GB" & vbCrLf & _
"Free Space ........... " & Int(objItem.FreeSpace /1073741824) & " GB"
next
End Sub

COMP230_Wk5_Modular_Report.docx 2 Revision Date: 1213


Capture the Mod1_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.

COMP230_Wk5_Modular_Report.docx 3 Revision Date: 1213


COMP230_Wk5_Modular_Report.docx 4 Revision Date: 1213
COMP230_Wk5_Modular_Report.docx 5 Revision Date: 1213
Copy your Mod2_PCTests.vbs program from NotePad++ and paste it into the space provided below.

'Noemi Matos
'01-June-2016
'Week 5 iLab
'COMP230 - Prof. Sasha Perez

' Menu Driven Computer / Network Tests


' This VBScript program is run using the PC_Tests.cmd Batch Script
Set args = WScript.Arguments
WScript.Echo vbCrLf
Set fso = CreateObject("Scripting.FileSystemObject")
Set vbsLib =
fso.OpenTextFile("C:\Users\user\Desktop\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 Printers_Status
Case "5"
Call Logical_HDD_Information
Case Else
WScript.Echo chr(7) & chr(7) & "Error, Choices are 1..5 or x!!!"
End Select

COMP230_Wk5_Modular_Report.docx 6 Revision Date: 1213


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.

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%")
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."
next
End Sub
Sub OS_Version
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
next
End Sub
Sub Printers_Status
strComputer ="."
intPrinters = 1
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_Printer")
WScript.Sleep(1000)
For Each objItem In colItems
WScript.Echo _

COMP230_Wk5_Modular_Report.docx 7 Revision Date: 1213


"Printer: " & objItem.DeviceID & vbCrLf & _
"===============================================" & vbCrLf & _
"Driver Name ............. " & objItem.DriverName & vbCrLf & _
"Port Name ............... " & objItem.PortName & vbCrLf & _
"Printer State ........... " & objItem.PrinterState & vbCrLf & _
"Printer Status .......... " & objItem.PrinterStatus & vbCrLf & _
"Print Processor ......... " & objItem.PrintProcessor & vbCrLf & _
"Spool Enabled ........... " & objItem.SpoolEnabled & vbCrLf & _
"Shared .................. " & objItem.Shared & vbCrLf & _
"ShareName ............... " & objItem.ShareName & vbCrLf & _
"Horizontal Res .......... " & objItem.HorizontalResolution & vbCrLf & _
"Vertical Res ............ " & objItem.VerticalResolution & vbCrLf
intPrinters = intPrinters + 1
next
End Sub
Sub Logical_HDD_Information
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where FreeSpace > 0")
For Each objItem in colItems
WScript.Echo vbCrLf & _
"========================================" & vbCrLf & _
"Drive Letter ......... " & objItem.Name & vbCrLf & _
"Description .......... " & objItem.Description & vbCrLf & _
"Volume Name .......... " & objItem.VolumeName & vbCrLf & _
"Drive Type ........... " & objItem.DriveType & vbCrLf & _
"Media Type ........... " & objItem.MediaType & vbCrLf & _
"VolumeSerialNumber ... " & objItem.VolumeSerialNumber & vbCrLf & _
"Size ................. " & Int(objItem.Size /1073741824) & " GB" & vbCrLf & _
"Free Space ........... " & Int(objItem.FreeSpace /1073741824) & " GB"
next
End Sub

COMP230_Wk5_Modular_Report.docx 8 Revision Date: 1213


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.

COMP230_Wk5_Modular_Report.docx 9 Revision Date: 1213


COMP230_Wk5_Modular_Report.docx 10 Revision Date: 1213
COMP230_Wk5_Modular_Report.docx 11 Revision Date: 1213

You might also like