ATS : Windows Registry Operations

Introduction

This page shows you how to work with the Windows registry using ATS.

Working with the Windows registry can be dangerous for the stability of your system.
We do not have a way to restore any changes made by your tests. We recommend executing them in some VM/container and have a restore option like VM snapshots.



First make an instance of the RegistryOperations class:

RegistryOperations regOperations = new RegistryOperations( SERVER_IP, RegistryOperations.HKEY_CURRENT_USER );

The first argument is the host to execute this code. You must have a running ATS Agent there. If you want to work locally, use the constructor without any the first argument.

The second argument specifies the root key path you will be working with.



Supported operations

Read a registry value

String regitryKeyPath = "Software\\Microsoft\\Internet Explorer\\Main";

regOperations.getStringValue( regitryKeyPath, "Some string key" );

regOperations.getIntValue( regitryKeyPath, "Some integer key" );

regOperations.getLongValue( regitryKeyPath, "Some long key" );

regOperations.getBinaryValue( regitryKeyPath, "Some binary key" );

Set a registry value

String regitryKeyPath = "Software\\Microsoft\\Internet Explorer\\Main";

regOperations.setStringValue( regitryKeyPath, "Some string key", "Some Key Value" );

regOperations.setIntValue( regitryKeyPath, "Some integer key", 20 );

regOperations.setLongValue( regitryKeyPath, "Some long key", 9000000000L );

regOperations.setBinaryValue( regitryKeyPath, "Some binary key", new byte[]{ 1, 2, 3, 4, 5 } );

Delete a registry key

String regitryKeyPath = "Software\\Microsoft\\Internet Explorer\\Main";

regOperations.deleteKey( regitryKeyPath , "Some key name" );

Create a registry key path

For example, if you want to have a Configuration folder for MyApplication for MyCompany, you need to run the following code:

regOperations.createPath( "Software\\MyCompany" );

regOperations.createPath( "Software\\MyCompany\\MyApplication" );

regOperations.createPath( "Software\\MyCompany\\MyApplication\\Configuration" );



Back to parent page

Go to Table of Contents