Need vbscript to write reg dword value
Hi,
I need a vbscript to write a REG_DWORD value.
Below is the key for which I want a vbscript.
HKCU\Software\Microsoft\Office\Frontpage\AddIns\PDMAddIn.Connect\LoadBehavior",dword:00000003
Can any one give the VB Script for this.
Thanks,
Sanhivi
I need a vbscript to write a REG_DWORD value.
Below is the key for which I want a vbscript.
HKCU\Software\Microsoft\Office\Frontpage\AddIns\PDMAddIn.Connect\LoadBehavior",dword:00000003
Can any one give the VB Script for this.
Thanks,
Sanhivi
0 Comments
[ + ] Show comments
Answers (6)
Please log in to answer
Posted by:
WSPPackager
14 years ago
Hi,
You can write the script in 2 mins. anyway, You can find the help here...http://msdn.microsoft.com/en-us/library/yfdfhz1b(VS.85).aspx
The script must be executed only when user is logged in. If you want to create the registry for every user whoever logon to that machine then run the script thru active setup.
let me know if you need more details.
regards
You can write the script in 2 mins. anyway, You can find the help here...http://msdn.microsoft.com/en-us/library/yfdfhz1b(VS.85).aspx
The script must be executed only when user is logged in. If you want to create the registry for every user whoever logon to that machine then run the script thru active setup.
let me know if you need more details.
regards
Posted by:
sanhivi
14 years ago
I have written the VB Script.
Option Explicit
On Error Resume Next
Dim WshShell
Set WshShell=CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\Microsoft\Office\Frontpage\AddIns\PDMAddIn.Connect\LoadBehavior","3","REG_DWORD"
It is working fine.
Thanks
Sanhivi
Option Explicit
On Error Resume Next
Dim WshShell
Set WshShell=CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\Microsoft\Office\Frontpage\AddIns\PDMAddIn.Connect\LoadBehavior","3","REG_DWORD"
It is working fine.
Thanks
Sanhivi
Comments:
-
hi, its working fine for me too but its not reflecting the changes if i am installing it through system context.. any idea on that as why its not working in system context? - Ishita Tripathi 7 years ago
-
You won't get user data in System Context...Use this script in ActiveSetup so it will be populated when the user logs in. - ur00361883 7 years ago
Posted by:
anonymous_9363
14 years ago
Posted by:
lkitsmiller
8 years ago
Below is the example code I found on the internet long ago complete with examples. I use it in almost all of my vbscript when editing, reading, changing the registry.
'-----------------------------------------------------
' Set Optional Registry Entries
'-----------------------------------------------------
Dim strKeyPath, iValues, oReg, BinaryValueName, DWordValueName, DWordValue
Dim StringValueName, StringValue
' Set Optional Registry Entries
'-----------------------------------------------------
Dim strKeyPath, iValues, oReg, BinaryValueName, DWordValueName, DWordValue
Dim StringValueName, StringValue
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set WShShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
userProfilePath = WSHShell.ExpandEnvironmentStrings("%UserProfile%")
WShShell.Popup "Optional Registry Entries being Updated.", 1, "Siemens Industry, Inc", 64
'-----------------------------------------------------
' Variables and Examples used in Registry Settings
'-----------------------------------------------------
' SetStringValue = REG_SZ
' SetDWORDValue = REG_DWORD
' SetBinaryValue = REG_BINARY
' SetExpandedStringValue = REG_EXPAND_SZ
' SetMultiStringValue =
' CreateKey
' DeleteKey
' DeleteValue
'Regtype should be “REG_SZ” for string, “REG_DWORD” for a integer,…
'”REG_BINARY” for a binary or boolean, and “REG_EXPAND_SZ” for an expandable string
'“REG_DWORD”
'strKeyPath = ""
'DWordValueName = ""
'DWordValue = ""
'oReg.SetDWordValue HKEY_LOCAL_MACHINE,strKeyPath, DWordValueName, DWordValue
Set WShShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
userProfilePath = WSHShell.ExpandEnvironmentStrings("%UserProfile%")
WShShell.Popup "Optional Registry Entries being Updated.", 1, "Siemens Industry, Inc", 64
'-----------------------------------------------------
' Variables and Examples used in Registry Settings
'-----------------------------------------------------
' SetStringValue = REG_SZ
' SetDWORDValue = REG_DWORD
' SetBinaryValue = REG_BINARY
' SetExpandedStringValue = REG_EXPAND_SZ
' SetMultiStringValue =
' CreateKey
' DeleteKey
' DeleteValue
'Regtype should be “REG_SZ” for string, “REG_DWORD” for a integer,…
'”REG_BINARY” for a binary or boolean, and “REG_EXPAND_SZ” for an expandable string
'“REG_DWORD”
'strKeyPath = ""
'DWordValueName = ""
'DWordValue = ""
'oReg.SetDWordValue HKEY_LOCAL_MACHINE,strKeyPath, DWordValueName, DWordValue
'”REG_BINARY”
'strKeyPath = ""
'iValues = Array(&H,&H)' Default = "00,00,00,00"
'BinaryValueName = ""
'oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,BinaryValueName,iValues
'strKeyPath = ""
'iValues = Array(&H,&H)' Default = "00,00,00,00"
'BinaryValueName = ""
'oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,BinaryValueName,iValues
'“REG_SZ”
'strKeyPath = ""
'StringValueName = ""
'StringValue = "" ' Default = "00000000"
'oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath, StringValueName, StringValue
'strKeyPath = ""
'StringValueName = ""
'StringValue = "" ' Default = "00000000"
'oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath, StringValueName, StringValue
'“REG_EXPAND_SZ”
'strKeyPath = ""
'StringValueName = ""
'StringValue = "" ' Default = "00000000"
'oReg.SetExpandedStringValue HKEY_CURRENT_USER,strKeyPath, StringValueName, StringValue
'strKeyPath = ""
'StringValueName = ""
'StringValue = "" ' Default = "00000000"
'oReg.SetExpandedStringValue HKEY_CURRENT_USER,strKeyPath, StringValueName, StringValue
Posted by:
lkitsmiller
8 years ago
Here's an actual example to see how everything is filled out:
'-----------------------------------------------------
' Show all SystemTray Icons
'-----------------------------------------------------
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer"
DWordValueName = "EnableAutoTray"
DWordValue = "00000000"
oReg.SetDWordValue HKEY_LOCAL_MACHINE,strKeyPath, DWordValueName, DWordValue
' Show all SystemTray Icons
'-----------------------------------------------------
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer"
DWordValueName = "EnableAutoTray"
DWordValue = "00000000"
oReg.SetDWordValue HKEY_LOCAL_MACHINE,strKeyPath, DWordValueName, DWordValue
Comments:
-
@lkitsmiller:
You seemed to have forgotten the declaration of the variable strComputer, and you'll also need to assign this variable a value like so:
strComputer = "."
This denotes that the system that you want to work with is the local system in your line:
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") - uncas1757 7 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.