On Error Resume Next
Dim arrErrors(),continue
Dim OS,SP
Dim completedSteps,totalSteps
'for memory test
Dim objWMIService, objComputer, colComputer
Dim strLogonUser, strComputer
'checkAntiVirus() Variables
Dim avInstalled,arrServices(),count
Set objExplorer = CreateObject ("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.Height = 800
objExplorer.Width = 800
objExplorer.Top = 1
objExplorer.Left = 1
'objExplorer.FullScreen = 1
objExplorer.Visible = 1
objExplorer.Document.Body.Style.Cursor = "wait"
objExplorer.Document.Body.Style.FontFamily = "Verdana, Arial, Helvetica, sans-serif"
objExplorer.Document.Body.Style.FontSize = "larger"
objExplorer.Document.Body.Style.BackgroundImage = "url(http://pltw.rit.edu/images/pltw_rit_logo_background.png)"
objExplorer.Document.Body.Style.BackgroundRepeat = "no-repeat"
objExplorer.Document.Body.Style.BackgroundPosition = "center"
objExplorer.Document.Title = "RIT - Project Lead the Way - System Check"
'Initialize some variables
continue = 1
strHTML = ""
completedSteps = 0
totalSteps = 4 'This is the number of steps it takes to complete this script. This used to show the progress.
getMac()
disableProxy()
checkAdmin()
checkWindowsUpdates()
checkMemory()
freeSpace()
checkAntiVirus()
allowContinue()
objExplorer.Document.Body.Style.Cursor = "default"
WScript.Quit(0)
'Start Functions
Function addHTML(txt)
strHTMLHead = "
Please wait while your computer is being analyzed...
"
strCompleted = "" & completedSteps & "% Completed
"
strHTML = strHTML + txt
objExplorer.Document.Body.InnerHTML = strHTMLHead + strCompleted + strHTML
End Function
Function setCompleted(num)
completedSteps = Fix(num / totalSteps * 100)
End Function
Function allowContinue()
Set regEx = New RegExp
With regEx
.Pattern = "129\.21\.\d{1,3}\.\d{1,3}"
.IgnoreCase = True
.Global = True
End With
'If colResults.Count > 0 Then 'The person has an RIT IP address
'If continue = 1 Then
'addHTML("You have passed all tests. Please raise your hand to be registered on the network. Please copy and paste this report into the submission box on our website.
")
'addHTML("
")
'Else
'addHTML("Please remedy all of the issues above and repeate this test.
")
' End If
'Else 'None RIT IP Address
If continue = 1 Then
addHTML("You have passed all tests. This computer is ready for PLTW. Please copy and paste this report into the submission box on our website. Please don't forget to include your name!
")
Else
addHTML("Please remedy all of the issues above and repeate this test.
")
End If
'End If
End Function
Function checkIP()
Set http = CreateObject("Microsoft.XMLHTTP")
http.open "GET","http://www.whatismyip.com/automation/n09230945.asp",False
http.send
checkIP = http.responseText
End Function
Function getMac()
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
addHTML("")
For Each objItem in colItems
If InStr(objItem.NetConnectionID,"Local") Or InStr(objItem.NetConnectionID,"Wireless") Then
addHTML("- "&objItem.NetConnectionID&" ("&objItem.Name&"): "&objItem.MACAddress&"
")
End If
Next
addHTML("
")
'addHTML("Open Claws
")
End Function
Function disableProxy()
'addHTML("Disable Internet Explorer Proxy...")
Set objShell = CreateObject("Wscript.Shell")
objShell.RegWrite "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",0,"REG_DWORD"
setCompleted(1)
'addHTML("Completed.
")
End Function
Function checkAdmin()
addHTML("Verifying that you are an Administrator...")
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
strUser = objNetwork.UserName
isAdmin = 0
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
For Each objUser in objGroup.Members
If objUser.Name = strUser Then
isAdmin = 1
End If
Next
setCompleted(2)
addHTML("Completed.
")
If isAdmin = 0 Then
addHTML("")
addHTML("- User "& strUser &" is NOT an Administrator...Failed
")
addHTML("
")
continue = 0
Else
addHTML("")
addHTML("- User "& strUser &" is an Administrator...Passed
")
addHTML("
")
End If
End Function
Function checkWindowsUpdates()
addHTML("Verifying Windows Updates...")
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
OS = objItem.Caption
SP = objItem.ServicePackMajorVersion
Next
If InStr(UCase(OS),"XP") > 0 Then 'If the user has XP
OS = ""&OS&"...Passed."
If SP > 2 Then 'If the user has SP3 or better
SP = "Service Pack: "&SP&"...Passed."
Else 'If the user does not have SP2 or better
SP = "Service Pack: "&SP&"...Failed. Please Update"
continue = 0
End If
ElseIf InStr(UCase(OS),"VISTA") > 0 Then 'If the user has Vista
OS = ""&OS&"...Passed"
If SP = 1 Then 'If the user has SP2 or better
SP = "Service Pack: "&SP&"...Passed"
End If
ElseIf InStr(UCase(OS),"WINDOWS 7") > 0 Then 'If user has Windwos 7
OS = ""&OS&"...Passed"
If SP = 0 Then 'If the user has SP or better
SP = "Service Pack: "&SP&"...Passed"
End If
Else 'If the user does not have XP or Vista
OS = ""&OS&"...Failed"
continue = 0
End If
Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher
Set colHistory = objSearcher.QueryHistory(1, 1)
For Each objHistory in colHistory
LastUpdateDate = objHistory.Date
arrDate = Split(LastUpdateDate, " ")
LastUpdateDaysAgo = DateDiff( "d", arrDate(0), Date)
If LastUpdateDaysAgo < 30 then
LastUpdateOK = "Last Update: " & LastUpdateDaysAgo & " days ago...Passed"
Else
LastUpdateOK = "Last Update: " & LastUpdateDaysAgo & " days ago...Failed Please Update"
continue = 0
End If
Next
setCompleted(3)
addHTML("Completed.
")
addHTML("- "&OS&"
- "&SP&"
- "&LastUpdateOK&"
")
End Function
Function checkAntiVirus()
count = 0
avInstalled = 0
addHTML("Verifying that Anti-Virus is installed...")
avs = Array("BITDEFNDER","KASPERSKY","ESET","TREND MICRO","F-SECURE","MCAFEE","NORTON","AVG","NORMAN","SYMANTEC","ANTI VIRUS")
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service",,48)
For Each objItem in colItems
For Each av In avs
If InStr(UCase(objItem.DisplayName),av) Then
ReDim Preserve arrServices(count)
arrServices(count) = objItem.DisplayName
count = count + 1
avInstalled = 1
End If
Next
Next
setCompleted(4)
If avInstalled = 0 Then
addHTML("Failed: No Anti-Virus Found.
")
continue = 0
Else
addHTML("Completed.
")
addHTML("")
For Each service In arrServices
addHTML("- "&service&"...Passed.
")
Next
addHTML("
")
End If
End Function
Function checkMemory()
Dim strLogonUser, strComputer
Dim objWMIService, objComputer, colComputer
Dim numMemory
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
'addHTML("Total RAM " & FormatNumber((objComputer.TotalPhysicalMemory)/1024/1024/1024,1) & " GB
")
numMemory = FormatNumber((objComputer.TotalPhysicalMemory)/1024/1024/1024,1)
If numMemory >= 2 then
addHTML( "Verifying RAM... Completed
*Total RAM: " & numMemory & " ...Passed
")
Else
addHTML("Verifying RAM... Completed
Total RAM: " & numMemory & " ...Failed ")
continue = 0
End If
Next
setCompleted(5)
End Function
Function freeSpace()
Dim iSpc, strComputer, objWMIService
Dim fso, fsHandle, MyShell, colItems, objItem
Dim numFreeSpace
Set MyShell = CreateObject("Wscript.Shell")
strComputer = "."
Set objWMIService = GetObject _
( "winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 3")
For Each objItem in colItems
'Retrieve free space & convert from uint64
iSpc = cDbl(iSpc) + cDbl(objItem.FreeSpace)
Next
iSpc= iSpc/1024
iSpc= iSpc/1024
iSpc= iSpc/1024
iSpc= FormatNumber(iSpc,1)
setCompleted(6)
'addHTML("Free Space " & iSpc & " GB
")
numFreeSpace = iSpc
addHTML( "Verifying Free Hard Drive Space... Completed")
If numFreeSpace >= 30 then
addHTML("
*Total Free Space: " & numFreeSpace & " ...Passed
")
Else
addHTML("
Total Free Space: " & numFreeSpace & " ...Failed
")
continue = 0
End If
End Function