/build/static/layout/Breadcrumb_cap_w.png

Write in both 32/64 bit registry in Windows

I know there have been some questions so I found a basic script and added some extra stuff like DWORD, delete keys and I hope you can use it, this example is to set Java in both 64 and 32 bit not to auto update since you need both versions installed if you have both types of browsers in win7

In the link below you can see what syntax is need for other types like QWORD etc

const HKEY_LOCAL_MACHINE = &H80000002
' By René Meyer - December 2011
' Read/write a REG_SZ/dword value from the local computer's registry using WMI.
' Parameters:
' RootKey - The registry hive (see http://msdn.microsoft.com/en-us/library/aa390788(VS.85).aspx for a list of possible values).
' Key - The key that contains the desired value.
' Value - The value that you want to get/set.
' RegType - The registry bitness: 32 or 64.
' example on how to read a value
' sVersion = GetStringValue (HKEY_LOCAL_MACHINE, "SOFTWARE\MyOwnKey", "Value", 32)
' wscript.echo sVersion
' example on how to set a Reg_SZ
' SetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\MyOwnKey", "Value", "Data", 64
' example on how to set a DWord
' SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\MyOwnKey", "Value", "0", 32
' example on how to delete a value
' DeleteValue HKEY_LOCAL_MACHINE, "SOFTWARE\MyOwnKey", "ValueToDelete", 64


'writes a string value
SetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "Country", "US", 64
SetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "Country", "US", 32

'writes a DWORD value
SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "EnableAutoUpdateCheck", "0", 64
SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "EnableAutoUpdateCheck", "0", 32

SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "EnableJavaUpdate", "0", 64
SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "EnableJavaUpdate", "0", 32

SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "NotifyDownload", "0", 64
SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "NotifyDownload", "0", 32

SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "NotifyInstall", "0", 64
SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "NotifyInstall", "0", 32

SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "UpdateSchedule", "0", 64
SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "UpdateSchedule", "0", 32

SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "Frequency", "0", 64
SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "Frequency", "0", 32

SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "UpdateMin", "0", 64
SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Update\Policy", "UpdateMin", "0", 32

DeleteValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SunJavaUpdateSched", 64
DeleteValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SunJavaUpdateSched", 32


Function GetStringValue (RootKey, Key, Value, RegType)
Dim oCtx, oLocator, oReg, oInParams, oOutParams

Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", RegType

Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")

Set oInParams = oReg.Methods_("GetStringValue").InParameters
oInParams.hDefKey = RootKey
oInParams.sSubKeyName = Key
oInParams.sValueName = Value

Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)

GetStringValue = oOutParams.sValue

set oCtx = Nothing
set oLocator = Nothing
End Function


Sub SetStringValue (RootKey, Key, ValueName, Value, RegType)
Dim oCtx, oLocator, oReg, oInParams, oOutParams

Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", RegType

Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")

Set oInParams = oReg.Methods_("SetStringValue").InParameters
oInParams.hDefKey = RootKey
oInParams.sSubKeyName = Key
oInParams.sValueName = ValueName
oInParams.sValue = Value

oReg.ExecMethod_ "SetStringValue", oInParams, , oCtx

Set oCtx = Nothing
Set oLocator = Nothing
End Sub

Sub SetDWORDValue (RootKey, Key, ValueName, Value, RegType)
Dim oCtx, oLocator, oReg, oInParams, oOutParams

Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", RegType

Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")

Set oInParams = oReg.Methods_("SetDWORDValue").InParameters
oInParams.hDefKey = RootKey
oInParams.sSubKeyName = Key
oInParams.sValueName = ValueName
oInParams.uValue = Value

oReg.ExecMethod_ "SetDWORDValue", oInParams, , oCtx

Set oCtx = Nothing
Set oLocator = Nothing
End Sub

Sub DeleteValue (RootKey, Key, Value, RegType)
Dim oCtx, oLocator, oReg, oInParams, oOutParams

Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", RegType

Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")

Set oInParams = oReg.Methods_("DeleteValue").InParameters
oInParams.hDefKey = RootKey
oInParams.sSubKeyName = Key
oInParams.sValueName = Value

Set oOutParams = oReg.ExecMethod_("DeleteValue", oInParams, , oCtx)

set oCtx = Nothing
set oLocator = Nothing
End Sub

0 Comments   [ + ] Show comments

Answers (0)

Be the first to answer this question

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

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