Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Applying Hex Value to Registry

80 views
Skip to first unread message

Maro

unread,
Nov 29, 2005, 3:09:03 PM11/29/05
to
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

Message has been deleted

W C Hull

unread,
Nov 30, 2005, 12:11:12 AM11/30/05
to
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_t...@hotmail.com> wrote in message
news:438ce581$0$20859$9b4e...@newsread2.arcor-online.net...

> '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


Maro

unread,
Nov 30, 2005, 8:51:02 AM11/30/05
to
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

0 new messages