List object methods and properties

后端 未结 6 1599
有刺的猬
有刺的猬 2020-12-31 00:12

Is there any way to list available methods for created object in VBS?

For example:

Set IE = CreateObject(\"InternetExplorer.Application\")

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-31 00:46

    While that is partially true, its incomplete.... Google, GetObjectText_, Methods_, & Propeties_

    The referenced methods will only work on objects collected while connected to the cimv2 namespace of a remote host via the WbemScripting.SWbemLocator object. If this object has the ability to work on localhost, it's unapparent to me.

    Once you do this you can query any of the classes held therein [Win32_Services,Win32_Drives, etc] and interrogate the objects in the resultset using a For-Next loop on the object like below...

    For Each oProp in oObject.Properties_
        'be careful here because some propeties may be an object or an array.
        'so test for that here using "typename" or "vartype"
        wScript.Echo oProp.Name & vbTab & oProp
    Next
    

    Or...

    For Each oMethod in oObject.Methods_
        wScript.Echo oProp.Name
    Next
    

    Finally, ...

    For Each oProp in oObject.Properties_
       'This will display all of an objects properties
       oProp.GetObjectText_
    Next
    

提交回复
热议问题