OLE – RegEdit

Here are some scripts that access the Windows Register via OLE.


The following script is really simple, and uses WScript.shell

FUNCTION registry_read(key_path as string, key_name as string)
' reads a fully specified key
' e.g. message = registry_read("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\\", "SystemDirectory")
dim registry = CreateObject("WScript.shell")
registry_read = registry.regread(key_path & key_name)
' all local variables in a SUB and in a FUNCTION are automatically released on exit/end
END function

And here are two examples of it being used

message = "SystemDirectory: " & registry_read("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\\", "SystemDirectory")


message = "RegisteredOwner: " & registry_read("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOwner", "")


I have one generic script that queries the Register and displays the response. Included are 3 invocations of the generic script.

This is a fairly complex script that uses OLE and Wbemscripting.

You can find the script here NS-RegistryReadsUsingWbemScripting.


There is a script that focuses on querying the  StdRegProv service.

Again it uses OLE and Wbemscripting.

You can find the script here NS-Display-StdRegProv-Interface