How to add a registry key using VBScript?

43,828

An example of registry entry creation would be:

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Script Center"
strValueName = "My DWORD Value"
dwValue = 13

objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue

where the targets can be changed accordingly to your needs.

Source

Share:
43,828
powermun50
Author by

powermun50

Updated on September 18, 2022

Comments

  • powermun50
    powermun50 over 1 year

    I want to add a registry key (DWORD=1) in HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet\Control\StorageDevicePolicies using VBScript. How can I do that?

  • powermun50
    powermun50 about 11 years
    I am sorry. But i didn't understand. can you give me exact script for HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet \Control\StorageDevicePolicies?
  • MDMoore313
    MDMoore313 about 11 years
    @powermun50 if you can't rewrite this script to suit your needs you probably shouldn't be editing the registry.
  • Karan
    Karan about 11 years
    @MDMoore313: Very well said!