FYI - Using WMI's StdRegProv to access the Registry
I just happened upon an interesting post in the microsoft.public.wbem newsgroup (i.e., WMI stuff for
those of you who don't hang out over there ;-) - Subject: "Accessing the registry with STDREGPROV".
I actually looked at the StdRegProv in an early release of WMI when you had to create and register a
MOF (whatever that is ;-) and decided it was too much trouble at the time.
But with WMI (version 1.5 at least, which is the current downloadable version), StdRegProv doesn't
require any of the original MOF-ing around.
You can do registry access very simply, including enumerating key and value names (things not
possible with WshShell registry methods).
The VBScript example below is from a VB example (in the WMI docs) that was trivial to adapt to
VBScript. Unfortunately the code can't be adapted for JScript since it uses by reference method
arguments. But I just ran this on a Win98 box and it works like a charm...
set objRegistry = GetObject("winmgmts://./root/default:StdRegProv")
'Assumes objRegistry is a valid StdRegProv object.
Const HKEY_LOCAL_MACHINE = &H80000002
Dim lRC '==> As Long
Dim sPath '==> As String
Dim sKeys() '==> As Variant
sPath = "SOFTWARE\Microsoft\Windows"
On Error Resume Next
lRC = objRegistry.EnumKey(HKEY_LOCAL_MACHINE, sPath, sKeys)
If (lRC <> 0) or (Err.Number <> 0) Then
'An error occurred
On Error GoTo 0
Please do not email questions - post them to the newsgroup...