[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.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

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!

7.4

Vbs script convert to excel Macro to find Ram slots and size

Asked by bsharath in Microsoft Excel Spreadsheet Software, Programming Languages, Microsoft Office Suite

Tags: Excel, Macro, Script, Language

Hi,
The below Vbs file gets the Ram slots and the free slot details of all the machines in the file with the size per Bank.
I have the machine names in Colum Q
Need the output as such.
Total Slots       Free Slots              Bank1             Bank2            Bank3            Bank4
^ Colum "AE"      ^ Colum "AF"     ^"AG"           ^"AH"          ^"AI"               ^"AJ"  

If the cell is blank then leave the cell blank without any output.
If machine not contactable then leave blank cells.

After the first time the macro is run.It need to just run on the cells that has no data.

REgards
Sharath
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
 
Related Solutions
Keywords: Vbs script convert to excel Macro to fi…
 
Loading Advertisement...
 
[+][-]02/17/08 06:00 PM, ID: 20917049Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/17/08 06:43 PM, ID: 20917187Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/17/08 06:43 PM, ID: 20917188Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/17/08 07:01 PM, ID: 20917262Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/17/08 07:01 PM, ID: 20917263Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/17/08 07:09 PM, ID: 20917292Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/17/08 07:38 PM, ID: 20917422Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/17/08 07:38 PM, ID: 20917423Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/17/08 07:41 PM, ID: 20917433Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/17/08 07:52 PM, ID: 20917458Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Microsoft Excel Spreadsheet Software, Programming Languages, Microsoft Office Suite
Tags: Excel, Macro, Script, Language
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 1
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81 / EE_QW_EXPERT_20070906