Creating Registry Keys

To create keys and subkeys in the registry, you use the CreateKey method, as illustrated in the CreateRegKey.vbs script:

Option Explicit On Error Resume Next Dim strKeyPath ' the portion of registry to read Dim strComputer ' the target computer Dim objReg ' holds connection to registry provider Dim subKey ' used to enumerate throught the array Dim arrSubKeys ' holds the sub keys Dim ParentKey Const HKCR = &H80000000 'HKEY_CLASSES_ROOT Const HKCU = &H80000001 'HKEY_CURRENT_USER Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE Const HKU = &H80000003 'HKEY_USERS Const HKCC = &H80000005 'HKEY_CURRENT_CONFIG ParentKey = "SOFTWARE\EdWilson" strKeyPath = "SOFTWARE\EdWilson\VBScriptBook" strComputer = "." Set objReg=GetObject("winmgmts:\\" ...

Get Microsoft® Windows® Scripting Self-Paced Learning Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.