如何使用 Test Complete 获取完整的计算机名称

How to get the full computer name using Test Complete

如何使用 Test Complete 获取完整的计算机名称

例如,

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

使用 TestComplete,我尝试了以下方法:

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

在这里,我缺少使用 TestComplete

获取“.COM”

请帮我弄到完整的电脑像RAMAKRISHNA.XYZ.COM

您可以使用 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 帮助主题。

如果有帮助,试试这个:

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