Look at http://www.lissware.net, Volume 1, Sample 1.01 to 1.25 -
WSHScript.vbs, which uses a series of functions.
In this list of functions, you will find two generic routines to play with:
ReadRegistryFunction.vbs and WriteRegistryFunction.vbs.

With these two, you are all set. I reproed the ReadRegistry one below.
Note that from the WSH object model, RegWrite method does not support
REG_MULTI_SZ.
If you need to update REG_MULTI_SZ, you need to use the WMI model. For this
see http://www.lissware.net, Vol 2, Sample 3.03 to 3.09 - WMIRegistry.wsf
(Second code exerpt below).

HTH.

' Author: Alain Lissoir ([EMAIL PROTECTED])

'
' ISBN 1555582664 - Understanding WMI Scripting (Digital Press)

' ISBN 1555582990 - Leveraging WMI Scripting (Digital Press)


' WSH Technique
----------------------------------------------------------------------------
--------------------
Private Function ReadRegistry (objFileName, strKeyName, KeyValueName,
strRegType)

Dim strRegKey
Dim varRegKeyValue()

Dim intIndice
Dim strTempValue

        On Error Resume Next

        strRegKey = strKeyName & "\" & KeyValueName
        WriteToFile objFileName, "** Reading registry '" & strRegKey & "'("
& strRegType & ")."

        strTempValue = WshShell.RegRead (strRegKey)
        If Err.Number Then
           ErrorHandler objFileName, "ReadRegistry", Err, boolErrorPopup
           Exit Function
        End If

        Select Case strRegType
               Case "REG_BINARY"
                    ReDim varRegKeyValue(Ubound(strTempValue))
                    For intIndice = 0 to Ubound(strTempValue)
                        varRegKeyValue (intIndice) = "&h" & Right("00" &
Hex(strTempValue(intIndice)), 2)
                        WriteToFile objFileName, _
                                    strRegKey & "(" & UCase(strRegType) & ")
-> " & varRegKeyValue(intIndice)
                    Next
                    
               Case "REG_DWORD"
                    ReDim varRegKeyValue(0)
                    varRegKeyValue(0) = "&h" & Hex (strTempValue)
                    WriteToFile objFileName, _
                                strRegKey & "(" & UCase(strRegType) & ") ->
" & varRegKeyValue(0)
               Case "REG_MULTI_SZ"
                    ReDim varRegKeyValue(Ubound(strTempValue))
                    For intIndice = 0 to Ubound(strTempValue)
                        varRegKeyValue (intIndice) = strTempValue(intIndice)
                        WriteToFile objFileName, _
                                    strRegKey & "(" & UCase(strRegType) & ")
-> " & varRegKeyValue(intIndice)
                    Next

               Case "REG_EXPAND_SZ"
                    ReDim varRegKeyValue(0)
                    varRegKeyValue(0) = WshShell.ExpandEnvironmentStrings
(strTempValue)
                    WriteToFile objFileName, _
                                strRegKey & "(" & UCase(strRegType) & ") ->
" & varRegKeyValue(0)
               Case Else
                    ReDim varRegKeyValue(0)
                    varRegKeyValue(0) = strTempValue
                    WriteToFile objFileName, _
                                strRegKey & "(" & UCase(strRegType) & ") ->
" & varRegKeyValue(0)
        End Select

        ReadRegistry = varRegKeyValue

End Function

' WMI technique
----------------------------------------------------------------------
Select Case intKeyType
               Case REG_SZ
                    intRC = objWMIClass.SetStringValue (intHiveType, _
                                                        strBaseKey, _
                                                        strKeyName, _
                                                        varKeyNameValue)
               Case REG_MULTI_SZ
                    intRC = objWMIClass.SetMultiStringValue (intHiveType, _
                                                             strBaseKey, _
                                                             strKeyName, _
 
varKeyNameValue)
               Case REG_EXPAND_SZ
                    intRC = objWMIClass.SetExpandedStringValue (intHiveType,
_
                                                                strBaseKey,
_
                                                                strKeyName,
_
 
varKeyNameValue)
               Case REG_BINARY
                    intRC = objWMIClass.SetBinaryValue (intHiveType, _
                                                        strBaseKey, _
                                                        strKeyName, _
                                                        varKeyNameValue)
               Case REG_DWORD
                    intRC = objWMIClass.SetDWORDValue (intHiveType, _
                                                       strBaseKey, _
                                                       strKeyName, _
                                                       varKeyNameValue)
        End Select

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon
Sent: Monday, October 17, 2005 8:25 AM
To: ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] Kix to VBS

Could I add multiple reg key changes to this vbs?  I would have to define a
new sPath at the end right?

-Devon

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Almeida Pinto,
Jorge de
Sent: Friday, October 14, 2005 5:51 PM
To: ActiveDir@mail.activedir.org; ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] Kix to VBS

Hi,
 
Try the following:
 
Cheers,
jorge
 
'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk
/wmi/enumvalues_method_in_class_stdregprov.asp
 
###########################
Const HKCU = &H80000001
Set
oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\defau
lt:StdRegProv")
sPath = "Software\IXOS"
On Error Resume Next
sKeyExist = False
oReg.EnumKey HKCU, sPath, arrSubKeys
For Each sSubKey In arrSubKeys
 If UCase(sSubKey) = "IXOS_ARCHIVE" Then
  sKeyExist = True
  Exit For
 End If
Next
Set sSubKey = Nothing
Set arrSubKeys = Nothing
If sKeyExist = True Then
 sPath = "Software\IXOS\IXOS_ARCHIVE\Viewer\Printing"
 On Error Resume Next
 oReg.EnumKey HKCU, sPath, arrSubKeys
 sKeyExist = False
 For Each sSubKey In arrSubKeys
  If UCase(sSubKey) = "FAX" Then
   sKeyExist = True
   Exit For
  End If
 Next
 Set sSubKey = Nothing
 Set arrSubKeys = Nothing
 If sKeyExist = False Then
  oReg.CreateKey HKCU, sPath & "\FAX"
  oReg.SetDWORDValue HKCU, sPath & "\FAX", "PaperSize", 1  Else
  On Error Resume Next
  oReg.EnumValue HKCU, sPath, arrValueNames, arrValueTypes
  sValueExist = False
  For Each sValue In arrValueNames
   If sValue = "PaperSize" Then
    sValueExist = True
    Exit For
   End If
  Next
  Set sValue = Nothing
  Set arrValueNames = Nothing
  Set arrValueTypes = Nothing
 
  If sValueExist = True Then
   oReg.GetDWORDValue HKCU, sPath & "\FAX", "PaperSize", MYValueData
   If MYValueData <> "1" Then
    oReg.SetDWORDValue HKCU, sPath & "\FAX", "PaperSize", 1
   End If
  Else
   oReg.SetDWORDValue HKCU, sPath & "\FAX", "PaperSize", 1
  End If
 End If
End If
###########################

________________________________

From: [EMAIL PROTECTED] on behalf of Harding, Devon
Sent: Fri 10/14/2005 7:48 PM
To: ActiveDir@mail.activedir.org
Subject: [ActiveDir] Kix to VBS



I'm having a tough time converting this kix script to ..vbs.  Any Ideas?

 

; This change will fix an IXOS problem where the default paper size is
A4 instead of Letter

If KeyExist("HKCU\Software\IXOS\IXOS_ARCHIVE") = 1

            If
KeyExist("HKCU\Software\IXOS\IXOS_ARCHIVE\Viewer\Printing\FAX") = 0

 
AddKey("HKCU\Software\IXOS\IXOS_ARCHIVE\Viewer\Printing\FAX")

            EndIf

            If
ReadValue("HKCU\Software\IXOS\IXOS_ARCHIVE\Viewer\Printing\FAX","PaperSi
ze") <> 1

 
WriteValue("HKCU\Software\IXOS\IXOS_ARCHIVE\Viewer\Printing\FAX","PaperS
ize","1","reg_dword")

            EndIf

EndIf

 

Devon Harding

Windows Systems Engineer

Southern Wine & Spirits - BSG

954-602-2469

 

________________________________

__________________________________
This message and any attachments are solely for the intended recipient and
may contain confidential or privileged information. If you are not the
intended recipient, any disclosure, copying, use or distribution of the
information included in the message and any attachments is prohibited. If
you have received this communication in error, please notify us by reply
e-mail and immediately and permanently delete this message and any
attachments. Thank You. 



This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to