'==========================================================================
'
' VBScript:  AUTHOR: Ed Wilson , MS,  12/15/2003
'
' NAME: <WriteToRegKey.vbs>
'
' COMMENT: Key concepts are listed below:
'1.use of constants for registry
'2. use of enumKey method
'3. use of StdRegProv
'4. Use of SetStringValue method
'5. Use of GetStringValue
'==========================================================================
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 subkeys
Dim ParentKey
Dim strNamedValue
Dim strData
Dim strReturnValue
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"
strNamedvalue = "book reviews"
strData = "Awesome"
	
strComputer = "."

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


objReg.SetStringValue HKLM, strKeyPath, strNamedValue, strData

WScript.Echo("value set")

objReg.GetStringValue HKLM, strKeyPath, strNamedValue, strReturnValue

WScript.Echo strNamedValue & " contains " & strReturnValue




