Re: Parsing binary values in the registry



I am having a little trouble getting your script to run in my code. I am
sure that I am doing something wrong. I am posting my current code. Maybe
you can point me in the right direction. I would appreciate it.

I am getting a subscript out of range "94" on line 18:

Dim wmiReg, FSO, binVal(), strVal, getVal, setVal, sHeader, sBody, sEnd

Const HKCU = &H80000001
Const HKLM = &H80000002
Const RegPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles\Outlook\7E7B781F8D24594194FDAA0E6FE65F65\"

Set wmiReg = GetObject("Winmgmts:Root/Default:StdRegProv")
Set FSO = CreateObject("Scripting.FileSystemObject")

If wmiReg.GetBinaryValue(HKCU, RegPath, "001f6700", binVal) <> 0 Then
WScript.Echo "Error Getting Registry Value."

Abytes = binVal
Dim A2(), U1, i

U1 = UBound(ABytes)
Redim A2(U1 \ 2)
For i = 0 to U1 Step 2
A2(i) = Chr(Abytes(i))
Next

PathString = Join(A2, "")
WScript.Echo PathString

"mayayana" <mayaXXyana1a@xxxxxxxxxxxxxxxx> wrote in message
news:sscye.3612$aY6.3085@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> If I understand that correctly:
> You're getting a unicode string as an array
> of bytes and you want to get the ANSI path
> string from that?
> So you get a numeric array like 87 00 67 00 68....?
>
> Assuming that ABytes is what was returned by
> GetBinaryValue. Also assuming that VBS can
> handle that byte array. I don't have a byte array handy to
> test this but it seems like it should work:
>
> Dim A2(), U1, i
>
> U1 = Ubound(ABytes)
> Redim A2(U1 \ 2)
> For i = 0 to U1 Step 2
> A2(i) = Chr(Abytes(i))
> Next
>
> PathString = Join(A2, "")
>
> What that does is to create an array half the size
> of your byte array, then step through the byte array,
> getting every second byte to skip the 00 bytes. Each
> of those is converted to an ANSI character and added
> to the A2 array. Once that's done you need only use
> Join on the A2 array to get your string.
>
> I'm not sure if that answers the first question. It sounds
> like you want to split an array of characters, but you
> say "an array of 32 length variables". What does that
> mean?
> --
> --
> Jim Gregg <jpgregg@xxxxxxx> wrote in message
> news:#uD72erfFHA.3940@xxxxxxxxxxxxxxxxxxxxxxx
>> Hello all,
>>
>> I have 2 questions if anyone can assist. First, I am wondering what is
>> the
>> best way to split a variable length value into an array of 32 length
>> variables. The size of the initial array can change from 32 to whatever.
>> Also, there is no splitting character such as tab or space. The initial
>> variable is just a series of values.
>>
>> Second, how can I take a variable length value and split it into an array
>> containing variables that have 4 characters. So, I need to take that long
>> value, take the first 4 characters, put that in a variable, go back to
>> the
>> original value, get the next 4, rinse and repeat. These 4 charatcer
>> values
>> are hex to unicode conversion, so I need to take the first two characters
>> from each 4 digit block and convert it to decimal and finally a
>> character.
>> Basically, I am trying to build a file path from a binary value in the
>> registry. Here is some example code:
>>
>> It is a bit of a mess at this time as I am just trying to write sections
> and
>> then bring it all together at the end:
>>
>> Const HKEY_CURRENT_USER = &H80000001
>>
>> strComputer = "."
>> Set StdOut = WScript.StdOut
>>
>> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
>> strComputer & "\root\default:StdRegProv")
>>
>> '*******************************************************
>> 'This section gets the default profile in Outlook
>> '*******************************************************
>>
>> strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
> Messaging
>> Subsystem\Profiles"
>> strValueName = "DefaultProfile"
>>
>> oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath, _
>> strValueName,strValue
>>
>> strProfile = strValue
>> StdOut.WriteLine strProfile
>>
>> '*******************************************************
>> 'This section gets each of the keys that hold PST file paths
>> '*******************************************************
>>
>> strProfilePath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
>> Messaging Subsystem\Profiles\" & strProfile &
>> "\9207f3e0a3b11019908b08002b2a56c2"
>> strProfileName = "01023d00"
>>
>> oReg.GetBinaryValue HKEY_CURRENT_USER,strProfilePath, _
>> strProfileName,strValue2
>> StdOut.WriteLine strProfilePath & "\" & strProfileName
>>
>>
>> For i = lBound(strValue2) to uBound(strValue2)
>>
>> If Len((Hex(strValue2(i)))) <> 2 then
>> strPathKeys = strPathKeys & "0" & Hex(strValue2(i))
>>
>> Else
>> strPathKeys = strPathKeys & Hex(strValue2(i))
>> End If
>> Next
>>
>> stdOut.WriteLine Len(strPathKeys)
>> stdOut.WriteLine strPathKeys
>>
>> '**********************************************************
>> 'This section breaks the above info into 32 bit values
>> '**********************************************************
>> No Code yet
>> '**********************************************************
>> '**********************************************************
>> 'The below section reads the reg keys that contain the binary version of
> the
>> file path
>>
>> strPSTPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
> Messaging
>> Subsystem\Profiles\" & strProfile & "\" & Left(strPathKeys, 32)
>> strPSTKey = "001f6700"
>>
>> oReg.GetBinaryValue HKEY_CURRENT_USER,strPSTPath, _
>> strPSTKey,strValue3
>> StdOut.WriteLine strPSTPath & "\" & strPSTKey
>>
>> For i = lBound(strValue3) to uBound(strValue3)
>>
>> If Len((Hex(strValue3(i)))) <> 2 then
>> strPSTKeys = strPSTKeys & "0" & Hex(strValue3(i))
>>
>> Else
>> strPSTKeys = strPSTKeys & Hex(strValue3(i))
>> End If
>> Next
>>
>> stdOut.WriteLine Len(strPSTKeys)
>> stdOut.WriteLine strPSTKeys
>> '*************************************************************
>> 'Testing Hex to Decimal, then Decimal to CHR
>> decimal = CLng("&H" & left(strPSTKeys,2))
>> stdOut.WriteLine decimal
>> stdOut.WriteLine Chr(decimal)
>>
>>
>
>


.



Relevant Pages

  • Parsing binary values in the registry
    ... The size of the initial array can change from 32 to whatever. ... containing variables that have 4 characters. ... StdOut.WriteLine strProfile ... Messaging Subsystem\Profiles\" & strProfile & ...
    (microsoft.public.scripting.vbscript)
  • Re: sending echo to all clients
    ... I did initialize it up properly, ... There is only one array and that is an array of pollfd structures named ... as an array of characters only but then I can't because sendsends bytes ... you receive C-style strings, so there's really no point to doing it. ...
    (comp.unix.programmer)
  • Re: Subquery Confusion
    ... Then I got this crazy idea that an Array can only contain a maximum ... number of characters, ... Then I decide that maybe I'm completely wrong with my query, ... it out of Excel VBA and spit it into Microsoft SQL Server Management ...
    (microsoft.public.excel.programming)
  • Re: ifstream::get() surprise
    ... Extracts characters and stores them into successive locations ... > null character into the next successive location of the array. ... since the rule is to post the shortest code suffering from the ...
    (comp.lang.cpp)
  • Re: Problem with inserting bytea into postgresql
    ... > This byte array is serialized object. ... > ByteArrayOutputStream outputStream = new ByteArrayOutputStream; ... and the characters are encoded via UTF-8. ...
    (comp.lang.java.help)

Loading