The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GetStringValue method of the StdRegProv class

The GetStringValue method returns the data value for a named value whose data type is REG_SZ.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.


uint32 GetStringValue(
  [in]  uint32 hDefKey = HKEY_LOCAL_MACHINE,
  string sSubKeyName,
  string sValueName,
  string sValue


hDefKey [in]

A registry tree, also known as a hive, that contains the sSubKeyName path. The default value is HKEY_LOCAL_MACHINE.

The following trees are defined in WinReg.h.

HKEY_CLASSES_ROOT (2147483648 (0x80000000))
HKEY_CURRENT_USER (2147483649 (0x80000001))
HKEY_LOCAL_MACHINE (2147483650 (0x80000002))
HKEY_USERS (2147483651 (0x80000003))
HKEY_CURRENT_CONFIG (2147483653 (0x80000005))

[in] A path that contains the named values.


[in] A named value whose data value you are retrieving. Specify an empty string to get the default named value.


[out] A data value for the named value.


The majority of registry values that hold useful information for a system administrator are made up of either alphanumeric characters (REG_SZ) or numbers (REG_DWORD). String values in the registry are often clearly interpretable words, such as the name of a component manufacturer. Registry values of other types, like binary values, cannot be interpreted quite so readily.

You can read REG_SZ and REG_DWORD values by using the GetStringValue and the GetDWORDValue methods, respectively.


The List Installed Applications on 32- or 64-Bit Computers VBScript code sample queries the registry for installed applications on either 32-bit or 64-bit systems.

The following VBScript sample returns a list of startup scripts displayed on a per-Group Policy Object (GPO) basis.

Const HKEY_LOCAL_MACHINE = &H80000002 
strComputer = "." 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _  
    strComputer & "\root\default:StdRegProv") 
strKeyPath = "Software\Policies\Microsoft\Windows\System\Scripts\Startup" 
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys 
For Each subkey In arrSubKeys 
    strValueName  = "DisplayName" 
    strGUIDVName  = "GPOName" 
    strFullKeyPath = strKeyPath & "\" & subkey 
    oReg.GetStringValue HKEY_LOCAL_MACHINE, strFullKeyPath, strValueName, szValue  
    oReg.GetStringValue HKEY_LOCAL_MACHINE, strFullKeyPath, strGUIDVName, szGPOName  
    wScript.Echo "Name and GUID of GPO deploying Startup Script = " & szValue & _ 
        "    " & szGPOName 
    oReg.EnumKey HKEY_LOCAL_MACHINE, strFullKeyPath, arrGPOSubKeys 
    For Each Scriptsubkey in arrGPOSubkeys 
        ' Script and parameters under subkeys 
        strScript = "Script" 
        strParam  = "Parameters" 
        strScriptKeyPath = strFullKeyPath & "\" & Scriptsubkey 
        oReg.GetStringValue HKEY_LOCAL_MACHINE, strScriptKeyPath, strScript, szScript  
        oReg.GetStringValue HKEY_LOCAL_MACHINE, strScriptKeyPath, strParam,  szParam  
        wScript.Echo "   Shutdown script = " & szScript 
        wScript.Echo "   Script Parameters = " & szParam 
        wScript.Echo "    " 


Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003







See also

Modifying the System Registry
WMI Tasks: Registry



© 2014 Microsoft