Using SiteRemote to Change Windows Registry Settings

The SiteRemote job system enables you to make Windows registry changes on your SiteKiosk Windows clients that are registered with your team. This can be used for example to change a Windows setting remotely or add a registry key to make Windows or an application behave differently than before.

The registry changes can be made in Javascript using methods of the Windows Script Host. The scripts can be distributed to the clients by creating a SiteRemote job with the action type 'Execute Script'.

After you selected the 'Execute Script' action type you can copy and paste the following to the script text box:

var gk_WshShell = new ActiveXObject("WScript.Shell");
//Create a test registry key 
gk_WshShell.RegWrite("HKLM\\Software\\SiteRemoteTest\\Test", "SiteRemote generated this registry key for testing purposes", "REG_SZ");

For this example, make sure to not enable the option 'Script requires SiteKiosk Object' as we want to first write to the HKEY_LOCAL_MACHINE (HKLM) part of the registry. If you enable the option, the script is executed with the rights of the user SiteKiosk is running under at the time of the script execution. Depending on the user rights writing to HKLM might not be possible. With the option disabled the script is executed with the full rights of the Local System Windows user.

The result will look like this if you view it with the Windows Registry Editor:

Note that the example uses the Software path, which means that on a 64-Bit system the entry will automatically be created under Wow6432Node as the client application executing the code is running in 32-Bit mode.

If you use the next example script as part of a SiteRemote script job you would change the entry that has been created by the code above:

var gk_WshShell = new ActiveXObject("WScript.Shell");
//Change the test registry key
gk_WshShell.RegWrite("HKLM\\Software\\SiteRemoteTest\\Test", "SiteRemote changed this registry key for testing purposes", "REG_SZ");

The next example would delete the test entry that has been created in the Windows registry:

var gk_WshShell = new ActiveXObject("WScript.Shell");
//Delete the test registry key
gk_WshShell.RegDelete("HKLM\\Software\\SiteRemoteTest\\");

As mentioned above, if you want to write to the registry hive of the user you are running SiteKiosk under, at the moment the job is executed on the client computer, you need to activate the option 'Script requires SiteKiosk Object'. This is normally used for executing SiteKiosk Object Model code, but it also means that the code is not executed with the System user the job would otherwise be running under.

The following example will do the same as the first one with the exception that it will write the key to the registry hive of the user (HKEY_CURRENT_USER or HKCU):

var gk_WshShell = new ActiveXObject("WScript.Shell");
//Create a test registry key 
gk_WshShell.RegWrite("HKCU\\Software\\SiteRemoteTest\\Test", "SiteRemote generated this registry key for testing purposes", "REG_SZ");

If you use HKCU and do not activate the option 'Script requires SiteKiosk Object' the key will be written to the hive of the System user.

Note that contrary to the examples that did not have the checkbox for the SiteKiosk Object enabled this one creates the key directly under the Software path, even on a 64-Bit system, as the client application responsible for executing the code under these circumstances is running in native mode.