System Properties and Functions

These are a miscellaneous collection of utility properties and functions that have been available in Silk Test Classic but were not available in Silk4NET, Silk4J, and Silk Test Workbench. These functions are now available across in all Silk Test clients.

What are these properties and functions?

The properties and functions are made available in the class named SystemFunctions. Each client exposes these in the manner that is appropriate for the language of the script, for example VB.Net, C#, or Java.

The functions and properties execute in the context of the Open Agent. In normal usage scenarios they execute on the local machine, however if the script is executing on a remote agent they are executed on the remote machine.

The following tables list the properties and functions that are available in the SystemFunctions class.


  • AgentDirectory
  • AgentVersion
  • ClipboardText
  • CurrentDrive
  • CurrentRegistryView
  • CursorPosition
  • CurrentWorkingDirectory
  • CursorType
  • FreeMemory
  • HostName
  • Locale
  • OSName
  • OSVersionType
  • OSVersion


  • CompareBinaryFiles()
  • CompareBitmaps()
  • CompareTextFiles()
  • CopyFile()
  • CreateDirectory()
  • CreateRegistryKey()
  • CreateRegistryValue()
  • DeleteRegistryKey()
  • DeleteRegistryValue()
  • DirectoryExists()
  • Execute()
  • ExistsRegistryKey()
  • ExistsRegistryValue()
  • FileClose()
  • FileExists()
  • FileOpen()
  • FileReadLine()
  • FileSetPointer()
  • FileWriteLine()
  • GetBitmapCRC()
  • GetDirectoryContents()
  • GetEnvironmentVariable()
  • GetFileInfo()
  • GetFreeDiskSpace()
  • GetRegistryKeyNames()
  • GetRegistryValueNames()
  • GetRegistryValue()
  • MoveFile()
  • RemoveDirectory()
  • RemoveFile()
  • SetEnvironmentVariable()
  • SetRegistryValue()

For more information on these properties and functions search the help for SystemFunctions.


The following examples show how to use some of the properties and functions in the SystemFunctions class. The code in these samples performs the following operations:

  1. Check for the existence of a file.
  2. If the file exists, open the file and read the first line.
  3. Type in the text from the file and the name of the operating system into the Notepad window.

Workbench - VB.Net

This is the code for a Workbench .Net script which uses VB.Net. The syntax is very similar to the code that could be used for a VB.Net script in Silk4NET.

Public Module Main
  Dim _desktop As Desktop = Agent.Desktop
  Public Sub Main()
    Dim sys = Agent.SystemFunctions
    Dim text = ""
    Dim filename = "C:\Temp\trigger.txt"
    If sys.FileExists(filename) = True Then
      Dim fileHandle = sys.FileOpen(filename, 
SystemFunctions.FileOpenMode.Read,                                     SystemFunctions.FileShareMode.DenyAll,                                     SystemFunctions.CharSet.ANSI)       text = sys.FileReadLine(fileHandle)       sys.FileClose(fileHandle)     End If     With _desktop.Window("Untitled - Notepad")       .SetActive()       .TextField("TextField").TypeKeys("Text = " + text +                                        ", OSName = " + 
sys.OSName +                                        "<Enter>")     End With   End Sub End Module

Silk4NET - C#

This is code for a Silk4NET test written in C#.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using SilkTest.Ntf;
namespace MySilkTextProject {
  public class UnitTest1 {
    private readonly Desktop _desktop = Agent.Desktop;
    public void TestMethod1() {
      var sys = Agent.SystemFunctions;
      var text = "";
      var filename = "C:\\Temp\\trigger.txt";
      if (sys.FileExists(filename)) {
        var fileHandle = sys.FileOpen(filename, 
SystemFunctions.FileOpenMode.Read,                                       SystemFunctions.FileShareMode.DenyAll,                                       SystemFunctions.CharSet.ANSI);         text = sys.FileReadLine(fileHandle);         sys.FileClose(fileHandle);       }       Window untitledNotepad = _desktop.Window("Untitled - Notepad");       untitledNotepad.SetActive();       untitledNotepad.TextField("TextField").TypeKeys("Text = " + text +                                                       ", OSName = " + 
sys.OSName +                                                       "<Enter>");     }   } }

Silk4J - Java

This is code for a Silk4J test using Java.

public void testMethod() {
  SystemFunctions sys = desktop.getSystemFunctions();
  String text = ""; 
  String filename = "C:\\Temp\\trigger.txt";
  if (sys.fileExists(filename)) {
      FileHandle fileHandle = sys.fileOpen(filename, 
SystemFunctions.FileOpenMode.READ, SystemFunctions.FileShareMode.DENY_ALL, SystemFunctions.CharSet.ANSI); text = sys.fileReadLine(fileHandle); sys.fileClose(fileHandle); } desktop.<TextField>find("Untitled - Notepad.TextField").typeKeys("Text = " + text + ", OSName = " +
sys.getOSName() + "<Enter>"); }


The addition of the SystemFunctions class to all the Silk Test clients gives scripting environments more power to perform actions and to retrieve information on the machine that is executing the test using a simple streamlined API.