OSInfo Object

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The OSInfo object holds the operating system information: the operating system name, version and edition, service pack version, .NET Framework count and versions, system folder paths and so on.

To obtain the OSInfo object that holds information about the PC’s operating system, use the OSInfo property of the Sys object.

Members

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

OSInfo Property
Sys Object
aqEnvironment Object

Highlight search results