Book Image

Advanced UFT 12 for Test Engineers Cookbook

Book Image

Advanced UFT 12 for Test Engineers Cookbook

Overview of this book

Table of Contents (18 chapters)
Advanced UFT 12 for Test Engineers Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 variable is as shown in the following code snippet:

Dim oWshShell, sKeyVal, sKeyPath, sKeyExpected

sKeyPath = "HKEY_CURRENT_USER\Environment\_JAVA_OPTIONS"
Set oWshShell = CreateObject("Wscript.Shell")
sKeyVal = oWshShell.RegRead(sKeyPath)

Print...