Advertisement
| Hall of Fame |
|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: |
Dim strTextFile,strComputer
Dim objFSO,objTextFile
Dim totalSlots,installedModules,strMemory
Dim colItems,oLogObject,sLogFile
Dim i,bEchoStatus
bEchoStatus = FALSE
If Wscript.Arguments.Count = 0 Then
Wscript.Echo "No filename was specified."
Wscript.Echo "Syntax: cscript getsysteminfo.vbs FileName"
Wscript.quit 1
Else
strTextFile = Wscript.Arguments(0)
End If
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strTextFile, ForReading)
sLogFile = "results.csv"
set oLogObject = CreateObject("Scripting.FileSystemObject")
If oLogObject.FileExists(sLogFile) Then
Err.Clear
On Error Resume Next
oLogObject.DeleteFile(sLogFile)
If Err.Number <> 0 then
msgbox "Unable to clear the result.csv file, Please make sure the file is closed"
WScript.Quit(0)
End if
On Error Goto 0
Err.Clear
End If
Do Until objTextFile.AtEndOfStream
strComputer = trim(objTextFile.ReadLine)
WScript.Echo
Wscript.Echo "Connecting to : " & strComputer
ScanMemory(strComputer)
Loop
objTextFile.Close
msgbox "Memory Details Enumeration Complete"
Sub ScanMemory(strComputer)
strMemory = ""
totalSlots = "N/A"
installedModules="N/A"
i = 1
Err.Clear
On Error Resume Next
set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 then
If bEchoStatus then Wscript.Echo "There has been an error connecting to the system : " & strComputer
LogDetails
Exit Sub
Else
If bEchoStatus then Wscript.Echo "Connected to the system, enumerating memory details..."
End If
Err.Clear
On Error Goto 0
Err.Clear
On Error Resume Next
set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
If Err.Number <> 0 then
If bEchoStatus then Wscript.Echo "There has been an error while accessing the Memory Details on : " & strComputer
totalSlots = "Error"
installedModules= "Error"
LogDetails
Exit Sub
End If
On Error Goto 0
For Each objItem In colItems
if strMemory <> "" then strMemory = strMemory & ","
strMemory = strMemory & (objItem.Capacity / 1048576) & " Mb"
i = i + 1
Next
installedModules = i - 1
Err.Clear
On Error Resume Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray")
If Err.Number <> 0 then
If bEchoStatus then Wscript.Echo "There has been an error while getting the Physical Memory Details on : " & strComputer
LogDetails
End if
Err.Clear
On Error Goto 0
For Each objItem in colItems
totalSlots = objItem.MemoryDevices
Next
LogDetails
End Sub
Sub LogDetails
If oLogObject.FileExists(sLogFile) Then
set oLogOutput = oLogObject.OpenTextFile(sLogFile, 8, True)
Else
set oLogOutput = oLogObject.CreateTextFile(sLogFile)
oLogOutput.WriteLine "Name,Total,Free,Bank1,Bank2,Bank3,Bank4"
End If
Dim tArray,tCount
tArray = split(strMemory,",")
tCount = UBound(tArray)
if tCount >0 then
For i=0 to tCount
strMemory = strMemory & "," & "nil"
Next
Elseif tCount=-1 then
oLogOutput.WriteLine strComputer & "," & totalSlots & "," & installedModules & "," & "nil" & "," & "nil" & "," & "nil" & "," & "nil"
oLogOutput.Close
Exit Sub
End if
For Each objItem in colItems
oLogOutput.WriteLine strComputer & "," & totalSlots & "," & "" & (totalSlots - installedModules) & "," & "" & strMemory
Next
oLogOutput.Close
End Sub
|