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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I use GetObject() to locate a compu

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I use GetObject() to locate a computer and pass on the object to another function (so it could do things like object.GetObject() to locate an NT Service.

However, I am having problem trying to read back the name of the computer from the Computer Object I obtained through
Code:
Set objComputer = GetObject("WinNT://compName,computer")

All the following results in Object required error, with or without the
Code:
CStr
:
Code:
CStr(objComputer.ComputerID)
CStr(objComputer)
CStr(objComputer.Class)


Note if I do the above before returning the Object at the function which does the GetObject, they all fail except objComputer.Class would work over there.

What is wrong?

 
MTL, you're Set statement was not successful. Try

On Error Resume Next
Set objComputer = GetObject("WinNT://compName,computer")
IF IsObject(objComputer) THEN
WScript.Echo objComputer.Class
WScript.Echo objComputer.Owner
ELSE
WScript.Echo "Bad connect string. Check for typos in the PC name."
END IF

Also, IIRC, the WinNT provider does not support the ComputerID property. Jon Hawkins
 
Thanks Jon, but it is the Computer Hostname /Windows Network Identifier I want, not the owner or the Class (i.e. Computer). However, If I do

Code:
WScript.echo CStr(objComputer.ComputerID )

I get error Active Directory: The Active Directory property cannot be found in the cache.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top