Name Property

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

Use the OSInfo.Name property to get the short name of the operating system installed on the current computer.

The OSInfo.Name property is useful when you want to test your application under different platforms. It lets you determine the current OS and include its name into the test log.

Declaration

OSInfoObj.Name

Read-Only Property String
OSInfoObj An expression, variable or parameter that specifies a reference to an OSInfo object

Applies To

The property is applied to the following object:

Property Value

The string that contains the name of the installed operating system. Possible values are:

Value Description
WinXP Windows XP or Windows Embedded 2009
WinVista Windows Vista
Win7 Windows 7 or Windows Embedded 7
Win8 Windows 8
Win81 Windows 8.1
Win10 Windows 10
Win2003 Windows Server 2003
Win2008 Windows Server 2008
Win2008R2 Windows Server 2008 R2
Win2012 Windows Server 2012
Win2012R2 Windows Server 2012 R2
Win10Ser Windows Server 2016 or Windows Server 2019

Example

The following example obtains information on the operating system and posts it to the test log.

JavaScript, JScript

function OSInfoSample()
{
  var OSInfo = Sys.OSInfo;

  // Obtains information on the running operating system
  var Info = "Name: " + OSInfo.Name + " ";

  if (OSInfo.Windows64bit)
    Info += "64-bit version" + "\r\n";
  else
    Info += "32-bit version" + "\r\n";

  Info += "Edition: " + OSInfo.Edition + "\r\n" +
        "Service Pack Version: " + OSInfo.ServicePackVersion + "\r\n" +
        "Version: " + OSInfo.Version;

  // Posts the information to the test log
  Log.Message("Operating system information:", Info);
}

Python

def OSInfoSample():
  OSInfo = Sys.OSInfo
  
  # Obtains information on the running operating system
  Info = "Name: " + OSInfo.Name + " "
  
  if OSInfo.Windows64bit:
    Info = Info + "64-bit version" + "\r\n"
  else:
    Info = Info + "32-bit version" + "\r\n"
  
  Info = Info + "Edition: " + OSInfo.Edition + "\r\n" +\
    "Service Pack Version: " + OSInfo.ServicePackVersion + "\r\n" +\
    "Version: " + OSInfo.Version
  
  # Posts the information to the test log
  Log.Message("Operating system information:", Info)

VBScript

Sub OSInfoSample
  Dim OSInfo, Info
  Set OSInfo = Sys.OSInfo

  ' Obtains information on the running operating system
  Info = "Name: " & OSInfo.Name & " "

  If OSInfo.Windows64bit Then
    Info = Info & "64-bit version" & vbNewLine
  Else
    Info = Info & "32-bit version" & vbNewLine
  End If

  Info = Info & "Edition: " & OSInfo.Edition & vbNewLine & _
        "Service Pack Version: " & OSInfo.ServicePackVersion & vbNewLine & _
        "Version: " & OSInfo.Version

  ' Posts the information to the test log
  Log.Message "Operating system information:", Info
End Sub

DelphiScript

procedure OSInfoSample;
var OSInfo, Info;
begin
  OSInfo := Sys.OSInfo;

  // Obtains information on the running operating system
  Info := 'Name: ' + OSInfo.Name + ' ';

  if OSInfo.Windows64bit then
    Info := Info + '64-bit version' + #13#10
  else
    Info := Info + '32-bit version' + #13#10;

  Info := Info + 'Edition: ' + OSInfo.Edition + #13#10 +
        'Service Pack Version: ' + OSInfo.ServicePackVersion + #13#10 +
        'Version: ' + OSInfo.Version;

  // Posts the information to the test log
  Log.Message('Operating system information:', Info);
end;

C++Script, C#Script

function OSInfoSample()
{
  var OSInfo = Sys["OSInfo"];

  // Obtains information on the running operating system
  var Info = "Name: " + OSInfo["Name"] + " ";

  if (OSInfo["Windows64bit"])
    Info += "64-bit version" + "\r\n";
  else
    Info += "32-bit version" + "\r\n";

  Info += "Edition: " + OSInfo["Edition"] + "\r\n" +
        "Service Pack Version: " + OSInfo["ServicePackVersion"] + "\r\n" +
        "Version: " + OSInfo["Version"];

  // Posts the information to the test log
  Log["Message"]("Operating system information:", Info);
}

See Also

FullName Property
Edition Property
Windows64bit Property
Version Property
ServicePackVersion Property
MediaCenter Property
TabletPC Property

Highlight search results