Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying colItems??? 1

Status
Not open for further replies.
Oct 10, 2003
90
US
Using the following


On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_TimeZone",,48)
Set colItems2 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)

For Each objItem in colItems

WScript.Echo "Current Time Zone: " & objItem.Description & vbCr & _
""
Next

For Each objItem in colItems2

WScript.Echo "UserName: " & objItem.UserName & vbCr & _
"PC Name: " & objItem.Name & vbCr & _
"Manufacturer: " & objItem.Manufacturer & vbCr & _
"Model: " & objItem.Model & vbCr & _
""
Next




How do I join the 2 collected items into a single popup box? I can't seem to correctly phrase my search criteria here or in Google, or perhaps it just can't be done.
 
Code:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_TimeZone",,48)
Set colItems2 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)

report = ""

For Each objItem in colItems

    report = report & vbCrLf & "Current Time Zone: " & objItem.Description & vbCr & _
     ""
Next

For Each objItem in colItems2

    report = report & vbCrLf & "UserName: " & objItem.UserName & vbCrLf & _
     "PC Name: " & objItem.Name & vbCrLf & _
     "Manufacturer: " & objItem.Manufacturer & vbCrLf & _
     "Model: " & objItem.Model & vbCrLf & _
     ""
Next

Wscript.Echo report

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Thanks Markdmac

I follow pretty much what you did, but the only line I am not understanding the purpose of is

report = ""

What is the purpose of that line?
 
I'm just setting the string with nothing there. If you look at the next place it is used:

report = report & vbCrLf & "Current Time Zone: " & objItem.Description & vbCr & _
""
I just like to have 'something' there that I am appending to.

This would work without it, and maybe somebody else would like to comment on the neccesity of it, but to me it is kind of like setting objects to 'nothing.' Closing the script does it to but nice to do it in your scripts anyway.

Hope that makes some sence.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
You might also want to Dim your variables all first at the top of your script.

Code:
Dim strComputer, objWMIService, colItems, colItems2, report, objItem

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top