1

How to get the full computer name using Test Complete

For example,

Computer Name : RAMAKRISHNA
Full Computer Name  : RAMAKRISHNA.XYZ.COM
Domain Name : XYZ.COM

Using TestComplete, I have tried the following:

log.Message sys.HostName    'Gives "RAMAKRISHNA"
log.Message sys.DomainName  'Gives "XYZ"

Here, I am missing to get ".COM" using TestComplete

Please help me to get the full computer like RAMAKRISHNA.XYZ.COM

2 Answers 2

2

You can do this using WMI.

Sub Test
  Log.Message getFullPCName  
End Sub 

Function getFullPCName
  Set cSystem = WMI.Service.InstancesOf("Win32_ComputerSystem").ItemIndex(0)
  getFullPCName = cSystem.Name & "." & cSystem.Domain
End Function

Windows Management Instrumentation technology provides ways to manage Windows settings and operations. You can use the Win32_ComputerSystem WMI class to get information on the system. TestComplete provides an easy way to work with WMI using the corresponding object. Find more information in the WMI Object help topic.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you Dmitry, This served my purpose. Can you please explain the code functionality or provide any article links that helps me to get the code
I have updated my response with some details. If my answer resolves your question, I would appreciate if you accept it.
Thanks a lot Dmitry :)
@rama-krishna, I am glad that I was able to help! Could you please mark my answer as accepted by clicking the check icon to the left of the answer text? :)
0

Try this if it helps:

Set wshShell = CreateObject( "WScript.Shell" ) 
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
WScript.Echo "Computer Name: " & strComputerName & "." & GetDomainName

Function GetDomainName()
  Dim Info 
  Set Info = CreateObject("AdSystemInfo") 
  GetDomainName = Info.DomainDNSName
End Function

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.