The following sample 'UsingRegistry' is shipped as part of the default installation, so the first thing to do is:

  • Go to the Rapise Start Page
  • Click on Fetch Samples to make sure that you have all the latest samples
  • Browse the samples to see the UsingRegistry sample.

The sample demonstrates the usage of the Windows Registry:

  • The sample gets the registry values to determine the OS type (Win7/8/10/2008/2012, etc)
  • The sample also gets the OS version and the Owner
  • The sample uses the standard object WScript.Shell and its method RegRead to access the Registry
//Creates an WScript.Shell object.
var shl = new ActiveXObject("WScript.Shell");

var osType = GetOsType();
Tester.Assert("The machins OS type", true, osType);

var osVersion = GetOsVersion();
Tester.Assert("The service pack version", true, osVersion);

var osOwner = GetOsOwner();
Tester.Assert("The registered owner of OS", true, osOwner);

/**
 * Reads OS type from registry.
 * @returns OS type.
 */

function GetOsType()
{
    return shl.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName");
}

/**
 * Reads OS service pack version from registry.
 * @returns Service pack version.
 */
function GetOsVersion()
{
    try
    {
        return shl.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\CSDVersion");
    }
    catch (e)
    {
        return "No service pack";
    }
}

/**
 *Reads OS registered owner from registry.
 *@returns OS registered owner.
 */
function GetOsOwner()
{
    return shl.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\RegisteredOwner");
}  

Further Reading

For more information on the Windows API / Scripting Host methods being used, please refer to: