/build/static/layout/Breadcrumb_cap_w.png

Deploy Registry changes with SMS using a script

While trying to recently deploy a registry change with SMS I found that a script solved the problem nicely when regedit /s failed. I have added the script here which you can then edit as required.

This script was used to create a new ODBC entry:

'==========================================================================

'

' VBScript: AUTHOR: Volante Desktop , 12/5/2008

'

' NAME:

'

' COMMENT: I have commented out entries not used in this script

' I plan to use this as a template of furture registry deployments

'==========================================================================

Option Explicit

On Error Resume Next

Dim strKeyPath ' the portion of registry to read

Dim strComputer ' the target computer

Dim strValueName 'holds the string key variable

Dim strValue ' holds the key value

'Dim dwValue ' holds the dword key value

Dim oReg ' holds connection to registry provider

'Const HKCR = &H80000000 'HKEY_CLASSES_ROOT

'Const HKCU = &H80000001 'HKEY_CURRENT_USER

Const HKLM = &H80000002 'HKLM

'Const HKU = &H80000003 'HKEY_USERS

'Const HKCC = &H80000005 'HKEY_CURRENT_CONFIG

strComputer = "."

Set StdOut = WScript.StdOut

'load the registry

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_

strComputer & "\root\default:StdRegProv")

'set path for the first change

strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"

strValueName = "ecprod"

strValue = "Oracle in 0800"

'apply the change to the registry

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

'set path for the second change to add a new key

strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ecprod"

oReg.CreateKey HKLM, strKeyPath

'reset the path for the next series of changes

strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ecprod"

'Set and apply the rest of the changes to the registry

strValueName = "Driver"

strValue = "k:\\ora\\r01\\Home\\0800\\BIN\\SQORA32.DLL"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Translation DLL"

strValue = ""

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Translation Option"

strValue = "10"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Attributes"

strValue = "w"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "PrefetchCount"

strValue = "10"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "ForceWCHAR"

strValue = "F"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "FailoverDelay"

strValue = "10"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "FailoverRetryCount"

strValue = "10"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "MetadataIdDefault"

strValue = "F"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Longs"

strValue = "F"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "CloseCursor"

strValue = "F"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "EXECSchemaOpt"

strValue = ""

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "EXECSyntax"

strValue = "F"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Application Attributes"

strValue = "T"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "SQLGetData extensions"

strValue = "F"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "ResultSets"

strValue = "T"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "QueryTimeout"

strValue = "T"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Failover"

strValue = "T"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Lobs"

strValue = "T"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "DisableMTS"

strValue = "T"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "BatchAutocommitMode"

strValue = "IfAllSuccessful"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Description"

strValue = "ecprod"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "ServerName"

strValue = "ecprod"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "Password"

strValue = ""

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "UserID"

strValue = ""

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

strValueName = "DSN"

strValue = "ecprod"

oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue

'Not used in this instance as used to set DWord value rather than string value

'kept here for future reference

'strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ecprod"

'strValueName = "DWORD Value Name"

'strValue = "value"

'dwValue = 10

'oReg.SetDWORDValue HKLM,strKeyPath,strValueName,dwValue


Comments

This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ