• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Scripting and Automation > Accessing the Registry from Scripts

9.3. Accessing the Registry from Scripts

The following code is used to write, read, and delete information in the Registry. Include the following three routines in your script:

Sub RegistryWrite(KeyName, ValueName, ValueData, ValueType)
  ValueType = UCase(ValueType)
  If ValueType <> "REG_DWORD" and ValueType <> "REG_BINARY" Then _
                                                   ValueType = "REG_SZ"
  Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.RegWrite KeyName & "\" & ValueName, ValueData, ValueType
End Sub

Function RegistryRead(KeyName, ValueName)
  Set WshShell = WScript.CreateObject("WScript.Shell")
  RegistryRead = WSHShell.RegRead(KeyName & "\" & ValueName)
End Function

Sub RegistryDelete(KeyName, ValueName)
  Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.RegWrite KeyName & "\" & ValueName, ""
  WshShell.RegDelete KeyName & "\" & ValueName
End Sub


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint