• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1164
  • Last Modified:

VBScript comparing binary registry key

iam having difficulty in comparing binary registry key. say for below code. the arrValue will return an array of numbers, what i want to do is compare the full set of values in this array to another binary key. e.g. Binaryvalue1= 020153001 if arrValue = Binaryvalue1 <--trying to put this into vbscript....... any help will be appreciated.

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\GroupOrderList"
strEntryName = "Base"
objReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath, _
'' strEntryName,arrValue
1 Solution
change linr 3 to the value you want
i copyed the registry key from your post if you need else change line 7 and 8
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
binary1 = 020153001
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\GroupOrderList"
strValueName = "Base"
oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
For i = lBound(strValue) to uBound(strValue)
    if  strValue(i) = binary1 Then
    WScript.Echo strValue(i) & " = " & binary1
    End If

Open in new window

this will covert to a user display string (same as regedit gives you) and cna be used in normal comparisons

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\GroupOrderList"
strEntryName = "Base"
objReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,arrValue

binstring = ""
for each b in arrValue
    if len(b) > 1 then
        binstring = binstring & hex(b)
        'pad byte with leading zero to keep consistent with display in regedit
        binstring = binstring & "0" & hex(b)
    end if

wscript.echo "Value:" & binstring
sydpoloAuthor Commented:
thank you, worked well.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now