vbscript 一个接一个地打印实例值

vbscript print instance values one after another

这是我的代码:

`strComputer = "." 
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\WMI") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM MSFC_FCAdapterHBAAttributes")
For each objItem in colItems 
        Wscript.Echo "Active: " & objItem.Active(0)
Next`

我得到这样的输出:

`Active: True` <br/>
`Active: True`

但我需要得到输出:Active: True, True

有人可以帮我解决这个问题吗?

此查询仅在 SAN 连接到服务器时有效,但您可以使用任何其他 class 等。

-卡卡-

你可以创建一个变量来存储它们,下面使用了strActives

strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\WMI")
Set colItems = objWMIService.ExecQuery("SELECT * FROM MSFC_FCAdapterHBAAttributes")
strActives = "" ' <-- Empty String here
For Each objItem In colItems
    If Len(strActives) > 0 Then strActives = strActives & ", " ' Append a comma if it is not empty
    strActives = strActives & objItem.Active(0) ' Append the value
Next
' Here only echo if the strActives is not empty
If Len(strActives) > 0 Then Wscript.Echo "Active: " & strActives