Deleting a key from the Windows® system registry

Automated tests rarely delete registry keys and values. However, in some cases (such as in the case described in the previous recipe), deleting the custom key would be a reasonable cleaning procedure. In this recipe, we will see how to do it.

Getting ready

From the File menu, navigate to New | Test, or use the Ctrl + N shortcut. You can use the same test as in the previous recipe.

How to do it...

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

object.RegDelete sKeyPath

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

For example, to delete the new custom string (REG_SZ) type key we created in the previous recipe, use the following code snippet:

Dim oWshShell, ...

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.