Hello,
I'm new to vbscript and i'm having a problem when i try to apply a registry
key. Here is my line of code:

WshShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState",
0c0002001b01e77760000000 "REG_DWORD"

I'm having trouble with the hex syntax. Would anyone know how to write this
correctly?

Thanks
--
-Maro

Re: Applying Hex Value to Registry by W

W
Tue Nov 29 23:11:12 CST 2005

Take a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__registry.asp

This doc will show you how to write values to the registry using WMI,
instead of the the standard regwrite statements. I've found this
methodology to be more powerful.


"Christoph Basedau" <e_tonne@hotmail.com> wrote in message
news:438ce581$0$20859$9b4e6d93@newsread2.arcor-online.net...
> 29.11.2005 21:09, Maro schrieb:
>> Hello,
>> I'm new to vbscript and i'm having a problem when i try to apply a
>> registry
>> key. Here is my line of code:
>>
>> WshShell.RegWrite
>> "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState",
>> 0c0002001b01e77760000000 "REG_DWORD"
>>
>> I'm having trouble with the hex syntax. Would anyone know how to write
>> this
>> correctly?
>
> '0c0002001b01e77760000000' is far too big for a DWORD.
> DWORD is a 32 bit unsigned long, whose max-value is
> 'FFFFFFFF' or 4,294,967,295 [Hex/Decimal].
> Numbers from 2^32 on need to be written as REG_BINARY; Writting Binary
> Values
> needs a different API then WSHShell.RegWrite, for example
> StdRegProv.SetBinaryValue.
> Also you either need to carefully build a variant array from the string or
> use
> a third party component for creating a binary-array from string, like e.g.
> 'ADs.ArrayConvert', which you can download here:
>
> http://support.microsoft.com/kb/q250344/
>
>
> Dim regPath
> Dim strValue
> Dim binArray
>
> Const HKEY_CURRENT_USER = &H80000001
>
> regPath =
> "Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState"
> binArray = Array(&Hc, &H0, &H2, &H0, &H1B, &H1, &HE7, &H77, &H60, &H0,
> &H0, &H0)
>
> ''alternatively create the binArray by component:
> 'Dim oCnvt
> 'Set oCnvt = CreateObject("ADs.ArrayConvert")
> 'binArray = oCnvt.CvHexStr2vOctetStr("0c0002001b01e77760000000")
>
> Set oStdRegProv = GetObject("Winmgmts:root\default:StdRegProv")
>
> Return = oStdRegProv.SetBinaryValue(HKEY_CURRENT_USER, _
> regPath, _
> "", _
> binArray )
>
> If (Return = 0) And (Err.Number = 0) Then
> Wscript.Echo "Binary value added successfully"
> Else
> Wscript.Echo "An error occurred"
> End If
>
>
>
>
>
> --
> Gruesse, Christoph
>
> Rio Riay Riayo - Gordon Sumner, 1979



Re: Applying Hex Value to Registry by bmarobel

bmarobel
Wed Nov 30 07:51:02 CST 2005

Thanks guys for responding. I'm new to vbscript, and scripting so i was a
little lost. From the links you sent me, i figured out how to do this with
WMI.

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
Set objRegProvider =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &
"\root\default:StdRegProv")

regPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState"
regValueName = "Settings"
binValueData = Array(&HC, &H0, &H2, &H0, &H1B, &H1, &HE7, &H77, &H60, &H0,
&H0, &H0)

objRegProvider.SetBinaryValue HKEY_CURRENT_USER, regPath, regValueName,
binValueData

Thanks for the help
--
-Maro


"W C Hull" wrote:

> Take a look at
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__registry.asp
>
> This doc will show you how to write values to the registry using WMI,
> instead of the the standard regwrite statements. I've found this
> methodology to be more powerful.
>
>
> "Christoph Basedau" <e_tonne@hotmail.com> wrote in message
> news:438ce581$0$20859$9b4e6d93@newsread2.arcor-online.net...
> > 29.11.2005 21:09, Maro schrieb:
> >> Hello,
> >> I'm new to vbscript and i'm having a problem when i try to apply a
> >> registry
> >> key. Here is my line of code:
> >>
> >> WshShell.RegWrite
> >> "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState",
> >> 0c0002001b01e77760000000 "REG_DWORD"
> >>
> >> I'm having trouble with the hex syntax. Would anyone know how to write
> >> this
> >> correctly?
> >
> > '0c0002001b01e77760000000' is far too big for a DWORD.
> > DWORD is a 32 bit unsigned long, whose max-value is
> > 'FFFFFFFF' or 4,294,967,295 [Hex/Decimal].
> > Numbers from 2^32 on need to be written as REG_BINARY; Writting Binary
> > Values
> > needs a different API then WSHShell.RegWrite, for example
> > StdRegProv.SetBinaryValue.
> > Also you either need to carefully build a variant array from the string or
> > use
> > a third party component for creating a binary-array from string, like e.g.
> > 'ADs.ArrayConvert', which you can download here:
> >
> > http://support.microsoft.com/kb/q250344/
> >
> >
> > Dim regPath
> > Dim strValue
> > Dim binArray
> >
> > Const HKEY_CURRENT_USER = &H80000001
> >
> > regPath =
> > "Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState"
> > binArray = Array(&Hc, &H0, &H2, &H0, &H1B, &H1, &HE7, &H77, &H60, &H0,
> > &H0, &H0)
> >
> > ''alternatively create the binArray by component:
> > 'Dim oCnvt
> > 'Set oCnvt = CreateObject("ADs.ArrayConvert")
> > 'binArray = oCnvt.CvHexStr2vOctetStr("0c0002001b01e77760000000")
> >
> > Set oStdRegProv = GetObject("Winmgmts:root\default:StdRegProv")
> >
> > Return = oStdRegProv.SetBinaryValue(HKEY_CURRENT_USER, _
> > regPath, _
> > "", _
> > binArray )
> >
> > If (Return = 0) And (Err.Number = 0) Then
> > Wscript.Echo "Binary value added successfully"
> > Else
> > Wscript.Echo "An error occurred"
> > End If
> >
> >
> >
> >
> >
> > --
> > Gruesse, Christoph
> >
> > Rio Riay Riayo - Gordon Sumner, 1979
>
>
>