Read Registry Value using VBScript

Description

In this article, I am going write VBScript samples to Read Registry Values like String, DWORD, Multi-String and Binary using WMI class ‘StdRegProv‘ and VBScript to get or read Remote Registry Value using WMI.

Summary

VBScript to Read String Registry Value using WMI

1. Copy the below example vbscript code and paste it in notepad or a VBScript editor.
2. Change the value for strKeyPath and strValueName with your own registry path and name.
3. Save the file with a .vbs extension, for example: ReadStringRegistryValue.vbs
4. Double-click the vbscript file (or Run this file from command window) to get String Registry value.

' ReadStringRegistryValue.vbs
' Sample VBScript to Read String Registry Value.
' Author: https://www.morgantechspace.com/
' ------------------------------------------------------
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set regObj=GetObject( _ 
    "winmgmts:{impersonationLevel=impersonate}!" & _
   strComputer & "rootdefault:StdRegProv")

strKeyPath = "SOFTWARE1App"
strValueName = "Name"
regObj.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Wscript.Echo "Application Name: " & strValue

WScript.Quit

In this article, we are going to Read Registry Value using VBScript from this Registry Path HKEY_LOCAL_MACHINESOFTWARE1App

Read Registry Value and Registry Key using VBScript via WMI

Read DWORD Registry Value using VBScript

' ReadDWORDRegistryValue.vbs
' Sample VBScript to Read DWORD Registry Value.
' Author: https://www.morgantechspace.com/
' ------------------------------------------------------
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set regObj=GetObject( _ 
    "winmgmts:{impersonationLevel=impersonate}!" & _
   strComputer & "rootdefault:StdRegProv")

strKeyPath = "SOFTWARE1App"
strValueName = "ProductID"
regObj.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
Wscript.Echo "Product ID: " & dwValue

WScript.Quit

VBScript to Read Multi-String Registry Value using WMI

1. Copy the below example vbscript code and paste it in notepad or a VBScript editor.
2. Change the value for strKeyPath and strValueName with your own registry path and name.
3. Save the file with a .vbs extension, for example: Read-Multi-String-Registry-Value.vbs
4. Double-click the vbscript file (or Run this file from command window) to get Multi-String Registry value using vbscript.

' Read-Multi-String-Registry-Value.vbs
' Sample VBScript to Read Multi-String Registry Value.
' Author: https://www.morgantechspace.com/
' ------------------------------------------------------
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set regObj=GetObject( _ 
    "winmgmts:{impersonationLevel=impersonate}!" & _
   strComputer & "rootdefault:StdRegProv")

strKeyPath = "SOFTWARE1App"
strValueName = "Languages"
regObj.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,arrValues
 For Each strValue In arrValues
    WScript.Echo  strValue
 Next
WScript.Quit

Read Binary Registry Value using VBScript

1. Copy the below example vbscript code and paste it in notepad or a VBScript editor.
2. Change the value for strKeyPath and strValueName with your own registry path and name.
3. Save the file with a .vbs extension, for example: Read-Binary-Registry-Value.vbs
4. Double-click the vbscript file (or Run this file from command window) to Read Binary Registry value using WMI in vbscript.

' Read-Binary-Registry-Value.vbs
' Sample VBScript to Read Binary Registry Value.
' Author: https://www.morgantechspace.com/
' ------------------------------------------------------
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set regObj=GetObject( _ 
    "winmgmts:{impersonationLevel=impersonate}!" & _
   strComputer & "rootdefault:StdRegProv")

strKeyPath = "SOFTWARE1App"
strValueName = "Certificate"
regObj.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,binValue

strBinData="" 
For i = lBound(binValue) to uBound(binValue)
strBinData=strBinData&" "&binValue(i)
Next

Wscript.Echo "Certificate: "& strBinData
WScript.Quit

Read Remote Registry Value using VBScript

1. Copy the below example vbscript code and paste it in notepad or a VBScript editor.
2. Change the value for strRemoteComputer with your own Remote Computer name to Read Registry Value.
3. Save the file with a .vbs extension, for example: Read-Remote-Registry-Value.vbs
4. Double-click the vbscript file (or Run this file from command window) to read Remote Registry Value using vbscript via WMI class.

' Read-Remote-Registry-Value.vbs
' Sample VBScript to Read Remote Registry Value.
' Author: https://www.morgantechspace.com/
' ------------------------------------------------------
const HKEY_LOCAL_MACHINE = &H80000002
strRemoteComputer = "your-Remote-PC"

Set regObj=GetObject( _ 
    "winmgmts:{impersonationLevel=impersonate}!" & _
   strRemoteComputer & "rootdefault:StdRegProv")

strKeyPath = "SOFTWARE1App"
strValueName = "Name"
regObj.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Wscript.Echo "Application Name: " & strValue

WScript.Quit

Advertisement

Leave a Comment