Comp230 Week 5

Topics: Batch file Pages: 14 (1799 words) Published: February 17, 2013
Student Name| Class| COMP230| Date| |
VBScript Modular Lab Report

' 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
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 = "."
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

' 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
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 = "."
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

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.

Sub...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • COMP230 Week 4 Essay
  • Comp230 Week 5 Essay
  • Comp230 Wk 5 Lab Essay
  • week 5 Essay
  • week 5 Essay
  • Week 5 Assignment 5 Essay
  • week 5 Essay
  • week 5 Research Paper

Become a StudyMode Member

Sign Up - It's Free