Reading a key from the Windows® system registry

Reading registry keys and values is an important task. For example, it can assist us in testing the correctness of an application installation process, or in reading specific settings of applications or even operating system environment variables. In this recipe, we will see how to read the value of a key from the registry, specifically the Java Options environment variable.

Getting ready

From the File menu, navigate to New | Test or use the Ctrl + N shortcut.

How to do it...

The syntax to retrieve the value of a registry key is as follows:

Registry_ReadKey

Here, object is an instance of the Wscript.Shell class and sKeyPath, a valid key.

An example of how to retrieve the value of the _JAVA_OPTIONS environment ...

Get Advanced UFT 12 for Test Engineers Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.