VersionInfo Property

Applies to TestComplete 15.0, last modified on October 14, 2021

Description

Use the VersionInfo property to obtain the version information associated with the file.

Declaration

aqFileInfoObj.VersionInfo

Read-Only Property An aqFileVersionInfo object
aqFileInfoObj An expression, variable or parameter that specifies a reference to an aqFileInfo object

Applies To

The property is applied to the following object:

Property Value

An aqFileVersionInfo object that contains version information for the file.

If the file does not contain any version information, the property returns a null object (Nothing in VBScript, nil in DelphiScript, None in Python, null in JavaScript, JScript, C++Script and C#Script).

Remarks

Version information can only be present in binary files (executables, DLLs and so on); text files do not have version information.

To obtain the version number of a running executable, you can use the Process.FileVersionInfo property.

Example

The following code snippet logs version information for Notepad:

JavaScript, JScript

function FileVersionInfoSample()
{
  var FileName = Sys.OSInfo.WindowsDirectory + "\\notepad.exe";
  var VerInfo = aqFileSystem.GetFileInfo(FileName).VersionInfo;

  Log.Message("File version: " +
              VerInfo.FileMajorVersion + "." +
              VerInfo.FileMinorVersion + "." +
              VerInfo.FileBuildVersion + "." +
              VerInfo.FileRevisionVersion);
  Log.Message("Description: " + VerInfo.FileDescription);
  Log.Message("Product: " + VerInfo.ProductName);
  Log.Message("Company: " + VerInfo.CompanyName);
}

Python

def FileVersionInfoSample():
  FileName = Sys.OSInfo.WindowsDirectory + "\\notepad.exe"
  VerInfo = aqFileSystem.GetFileInfo(FileName).VersionInfo
  Log.Message("File version: " + str(VerInfo.FileMajorVersion) + "." + str(VerInfo.FileMinorVersion) + "." + str(VerInfo.FileBuildVersion) + "." + str(VerInfo.FileRevisionVersion))
  Log.Message("Description: " + str(VerInfo.FileDescription[0]))
  Log.Message("Product: " + str(VerInfo.ProductName[0]))
  Log.Message("Company: " + str(VerInfo.CompanyName[0]))

VBScript

Sub FileVersionInfoSample
  Dim FileName, VerInfo

  FileName = Sys.OSInfo.WindowsDirectory & "\notepad.exe"
  Set VerInfo = aqFileSystem.GetFileInfo(FileName).VersionInfo

  Log.Message "File version: " & _
              VerInfo.FileMajorVersion & "." & _
              VerInfo.FileMinorVersion & "." & _
              VerInfo.FileBuildVersion & "." & _
              VerInfo.FileRevisionVersion
  Log.Message "Description: " & VerInfo.FileDescription
  Log.Message "Product: " & VerInfo.ProductName
  Log.Message "Company: " & VerInfo.CompanyName
End Sub

DelphiScript

procedure FileVersionInfoSample;
var FileName, VerInfo;
begin
  FileName := Sys.OSInfo.WindowsDirectory + '\notepad.exe';
  VerInfo := aqFileSystem.GetFileInfo(FileName).VersionInfo;

  Log.Message('File version: ' +
              VarToStr(VerInfo.FileMajorVersion) + '.' +
              VarToStr(VerInfo.FileMinorVersion) + '.' +
              VarToStr(VerInfo.FileBuildVersion) + '.' +
              VarToStr(VerInfo.FileRevisionVersion));
  Log.Message('Description: ' + VerInfo.FileDescription);
  Log.Message('Product: ' + VerInfo.ProductName);
  Log.Message('Company: ' + VerInfo.CompanyName);
end;

C++Script, C#Script

function FileVersionInfoSample()
{
  var FileName = Sys["OSInfo"]["WindowsDirectory"] + "\\notepad.exe";
  var VerInfo = aqFileSystem["GetFileInfo"](FileName)["VersionInfo"];

  Log["Message"]("File version: " +
              VerInfo["FileMajorVersion"] + "." +
              VerInfo["FileMinorVersion"] + "." +
              VerInfo["FileBuildVersion"] + "." +
              VerInfo["FileRevisionVersion"]);
  Log["Message"]("Description: " + VerInfo["FileDescription"]);
  Log["Message"]("Product: " + VerInfo["ProductName"]);
  Log["Message"]("Company: " + VerInfo["CompanyName"]);
}

See Also

Working With Files From Scripts
aqFileVersionInfo Object
FileVersionInfo Property

Highlight search results