Convert a Registry BINARY value into meaningful string

12,100

Solution 1

Ok. Use this bit of code to do your thing. See how I get the registry value and converts it.

Const HKEY_CURRENT_USER = &H80000001  
objreg = GetObject("winmgmts:" & _  
      "{impersonationLevel=impersonate}!\\" & _  
      strComputer & "\root\default:StdRegProv")  


objreg.GetBinaryValue HKEY_CURRENT_USER, "System\Majid", "FilePath", strRetVal  

MsgBox RegBinaryToString(strRetVal)  

function RegBinaryToString(arrValue)  
 strInfo=""  
  for i=0 to ubound(arrValue)  
   if arrValue(i)<>0 then strInfo=strInfo & chr(arrValue(i))  
  next  
 RegBinaryToString=strInfo  
end function  

Solution 2

Set objRegistry = CreateObject("Wscript.shell")
target = objRegistry.RegRead("HKCU\System\Majid\FilePath")
output = ""
for k = LBound(target,1) To UBound(target,1)
    output = output & chr(eval("&H"& hex(target(k))))
next
msgbox output
Share:
12,100
Inside Man
Author by

Inside Man

I am an ordinary man, even more ordinary than ordinary

Updated on June 05, 2022

Comments

  • Inside Man
    Inside Man almost 2 years

    I'm looking for a way or a Vbscript which can convert a registry key's binary value into a sting.

    For example think this is my key:

    [HKEY_CURRENT_USER\System\Majid]
    "FilePath"=hex:50,4f,2b,2a,90,93,e0,11,80,01,44,45,53,54,00,00
    

    It is translated to: PO+*گ“à€DEST

    But what does it mean really? I want to decode this strange value into meaningful word. If you can give me a simple vbscript which I can replace my key in it and receive the result, I'll really appreciate you a lot :)