首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

一段vbs ?解决办法

2012-01-29 
一段vbs? Get WMI Object.On Error Resume NextSet objWbemLocator CreateObject _(WbemScripting.SWb

一段vbs ?
' Get WMI Object.
On Error Resume Next
Set objWbemLocator = CreateObject _
("WbemScripting.SWbemLocator")

if Err.Number Then
WScript.Echo vbCrLf & "Error # " & _
" " & Err.Description
End If
On Error GoTo 0

On Error Resume Next

' If no errors then get Machine name, User name and Password.

Select Case WScript.Arguments.Count
Case 2

strComputer = Wscript.Arguments(0)
strQuery = Wscript.Arguments(1)
Set wbemServices = objWbemLocator.ConnectServer _ 
(strComputer,"Root\CIMV2")

   

Case 4
strComputer = Wscript.Arguments(0)
strUsername = Wscript.Arguments(1)
strPassword = Wscript.Arguments(2)
strQuery = Wscript.Arguments(3)
Set wbemServices = objWbemLocator.ConnectServer _ 
  (strComputer,"Root\CIMV2",strUsername,strPassword)


Case Else
strMsg = "Error # in parameters passed"
WScript.Echo strMsg
WScript.Quit(0)

End Select




Set wbemServices = objWbemLocator.ConnectServer _ 
(strComputer, namespace, strUsername, strPassword)

if Err.Number Then
WScript.Echo vbCrLf & "Error # " & _
" " & Err.Description
End If

On Error GoTo 0

On Error Resume Next

' Execute the given query.
' WScript.Echo "Query is " & Wscript.Arguments(4)
Set colItems = wbemServices.ExecQuery(strQuery)

if Err.Number Then
WScript.Echo vbCrLf & "Error # " & _
  " " & Err.Description
End If
On Error GoTo 0

' Process the output.
i=0
For Each objItem in colItems
if i=0 then
header = ""
For Each param in objItem.Properties_
header = header & param.Name & vbTab
Next
WScript.Echo header
i=1
end if
serviceData = ""
For Each param in objItem.Properties_
serviceData = serviceData & param.Value & vbTab
Next
WScript.Echo serviceData
Next

WScript.Quit(0)


这段程序是什么意思??谢谢

[解决办法]
WbemScripting.SWbemLocator ?
没见过。估计是一个人家自己写的COM组件,有他自己的作用。不是通用的
[解决办法]

探讨

WbemScripting.SWbemLocator ?
没见过。估计是一个人家自己写的COM组件,有他自己的作用。不是通用的

热点排行