We help IT Professionals succeed at work.

VB Script to Display the Value of a Registry Key

Evildragnor
Evildragnor asked
on
I need to determine the value of a registry key on several workstations.  Rather than lookup this key on each workstation  I would like a VB Script that will post the Value of the Key in a MsgBox.  The Key I need the value of is:

HKEY_LOCAL_MACHINE\SOFTWARE\InetCntrl\MacAddress

I have attempted this by modifing a script I found online, but I have made a large mess out of it.  Bad enough that I do not feel posting it would be help for anything other than entertainment value.  Any Help would be greatly appreciated.
Thanks in advance
Comment
Watch Question

Test your restores, not your backups...
Expert of the Year 2019
Top Expert 2016
Commented:
Try this.

~bp
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "SOFTWARE\InetCntrl"
strValueName = "MacAddress"
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
MsgBox("The MacAddress is: " & strValue)

Open in new window

Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016

Commented:
Just so you are aware, if you wanted to do this right from a command line (or BAT script) you can use:

reg query HKEY_LOCAL_MACHINE\SOFTWARE\InetCntrl /V MacAddress

~bp

Author

Commented:
Thanks!  Maybe one of these days I will get VBScript figured out.   I have found it can be very helpful & or  very frustrating, lol