Share via


StdRegProv class

The StdRegProv class contains methods that manipulate system registry keys and values. StdRegProv is preinstalled in the WMI namespaces root\default and root\cimv2.

Syntax

[dynamic, provider("RegProv"), AMENDMENT]
class StdRegProv
{
};

Members

The StdRegProv class has these types of members:

Methods

The StdRegProv class has these methods.

Method Description
CheckAccess Verifies that the user has the specified access permissions.
CreateKey Creates a subkey.
DeleteKey Deletes a subkey.
DeleteValue Deletes a named value.
EnumKey Enumerates subkeys.
EnumValues Enumerates the named values of a key.
GetBinaryValue Gets the binary data value of a named value.
GetDWORDValue Gets the DWORD data value of a named value.
GetExpandedStringValue Gets the expanded string data value of a named value.
GetMultiStringValue Gets the multiple string data values of a named value.
GetQWORDValue Gets the QWORD data values of a named value.
GetSecurityDescriptor Gets the security descriptor for a key.
GetStringValue Gets the string data value of a named value.
SetBinaryValue Sets the binary data value of a named value.
SetDWORDValue Sets the DWORD data value of a named value.
SetExpandedStringValue Sets the expanded string data value of a named value.
SetMultiStringValue Sets the multiple string values of a named value.
SetQWORDValue Sets the QWORD data values of a named value.
SetSecurityDescriptor Sets the security descriptor for a key.
SetStringValue Sets the string value of a named value.

Remarks

You can use the methods to perform the following tasks:

  • Verify the access permissions for a user.
  • Create, enumerate, and delete registry keys.
  • Create, enumerate, and delete named values.
  • Read, write, and delete data values.
  • Obtain or update the security descriptors for registry keys in scripts using Win32_SecurityDescriptor objects.

The RegProv registry provider is hosted in LocalService not the LocalSystem. Therefore, you cannot obtain information remotely from HKEY_CURRENT_USER, but you can run scripts locally. You can set the hosting model to LocalSystem on a remote machine, but the remote machine registry is vulnerable to hostile access, which is a security risk.

If your application uses a different namespace and requires access to the registry through WMI, you can compile the Managed Object Format (MOF) file that defines StdRegProv, RegEvent.mof, into that namespace for use by your application.

Although StdRegProv supplies only methods, a script or application can define a new class with properties that represent registry data for particular keys and store the classes in the WMI repository. Define the class as described in topics under Programming with the System Registry Provider.

While StdRegProv does not have methods to detect registry events, you can call methods like SWbemServices.ExecNotificationQuery or IWbemServices::ExecNotificationQuery with one of the following WMI registry event classes as TargetInstance in the query:

RegistryKeyChangeEvent
RegistryTreeChangeEvent
RegistryValueChangeEvent

Examples

The Get-Registry via StdRegProv PowerShell example retrieves values from the registry via the StdRegProv WMI class.

Requirements

Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Namespace
Root\default, Root\CIMv2
MOF
RegEvent.mof
DLL
Stdprov.dll

See also

Modifying the System Registry

System Registry Provider

WMI Tasks: Registry