Quote:
> I have not looked at WMI for
> alternative methods of posting to the registry so I will take a look into
> that. Do you know if that will handle large/long hex values
Yes.
SetBinaryValue Method in Class StdRegProv
http://msdn.microsoft.com/library/en-us/wmisdk/r_prov_6rzq.asp
From an old article:
<qoute>
Subject: Re: RegWrite errors
Newsgroups: microsoft.public.scripting.wsh
Date: 2001-02-19 07:16:27 PST
(this is probably a lot more than you expected and I spent a fair amount of time
(several hours) researching this ;-). But this question has come up so many
times without a really good answer that I thought it would be an interesting
exercise.)
RegObj.dll and also WMI's StdRegProv (Standard Registry Provider) both come
close. The problem is that both require a true byte array to write REG_BINARY
keys/values and VBScript can only create an array of variants of subtype byte.
There is hope for creating byte arrays in script (OK, a it's a free component
that creates them FOR script)!
Q250344 - SAMPLE: ARRAYCONVERT.EXE Variant Conversion Functions
http://support.microsoft.com/support/kb/articles/Q250/3/44.ASP
for a component (ADs.ArrayConvert) that helps with byte arrays. It was supposed
to be part of the ADSI SDK samples (but still isn't).
Here's a WMI StdRegProv example that uses it.
(Note: The code below isn't generally the way that I would use On Error Resume
Next. This example is adapted from WMI VB code examples. I suspect the On
Error Resume Next isn't really necessary. The long return value being non-zero
should be sufficient error checking. In the cases where I messed up
experimenting, I got non-zero return values, but no other runtime (Err object)
errors.)
'=====
' StdRegProv
' http://msdn.microsoft.com/library/psdk/wmisdk/regprovref_6yie.htm
'
' For info on the ADs.ArrayConvert component, see
'
' Q250344 - SAMPLE: ARRAYCONVERT.EXE Variant Conversion Functions
' http://support.microsoft.com/support/kb/articles/Q250/3/44.ASP
'
'=====
Dim objRegistry
set objRegistry = GetObject("winmgmts://./root/default:StdRegProv")
Const HKEY_LOCAL_MACHINE = &H80000002
Dim lRC
Dim sPath
Dim strHex
Dim binArray
Dim cnvt
Set cnvt = CreateObject("ADs.ArrayConvert")
strHex = "11223344"
binArray = cnvt.CvHexStr2vOctetStr(strHex)
'========IMPORTANT==========
' The key *MUST* already exist for
' a named value to be created or
' updated with SetBinaryValue() so
' we create it here. Note that it is
' NOT an error to call CreateKey() for
' a key that already exists...
'===========================
sPath = "SOFTWARE\MyKey"
On Error Resume Next
lRC = objRegistry.CreateKey(HKEY_LOCAL_MACHINE, sPath)
If (lRC = 0) And (Err.Number = 0) Then
'Do something
Else
'An error occurred
msgbox lrc
msgbox err.description
wscript.quit
End If
lRC = objRegistry.SetBinaryValue(HKEY_LOCAL_MACHINE, sPath, _
"MyBinaryNamedValue", binArray)
If (lRC = 0) And (Err.Number = 0) Then
'Do something
Else
'An error occurred
msgbox lrc
msgbox err.description
End If
================================================
</qoute>
Quote:
> or if there is
> a way to write those values with a RegWrite command??
There aren't.
--
torgeir