| The script below demonstrates the write, read | | | | Test"objRegistry.GetBinaryValue |
| and deletion for each type of value in the | | | | arrValues |
| Windows registry. | | | | For Each strValue In arrValues |
| The registry value types are: | | | | Wscript.Echo strValueName & " = " & strValue |
| - String (REG_SZ): A fixed-length text string. | | | | Next |
| - Binary (REG_BINARY): Raw binary data. Most | | | | 'Delete Binary valuestrKeyPath = "Registry |
| hardware component information is stored as | | | | Test"strValueName = "Binary |
| binary data and is displayed in Registry Editor in | | | | Test"objRegistry.DeleteValue |
| hexadecimal format. | | | | HKEY_CURRENT_USER,strKeyPath,strValueName |
| - DWORD (REG_DWORD): Data represented by | | | | 'Set DWORD valuestrKeyPath = "Registry |
| a number that is 4 bytes long (a 32-bit integer). | | | | Test"strValueName = "DWORD Test"intValue = |
| Many parameters for device drivers and services | | | | 123objRegistry.SetDWORDValue |
| are this type and are displayed in Registry Editor | | | | intValue |
| in binary, hexadecimal, or decimal format. | | | | 'Get DWORD valuestrKeyPath = "Registry |
| - Multi-String (REG_MULTI_SZ): A multiple string. | | | | Test"strValueName = "DWORD |
| Values that contain lists or multiple values in a | | | | Test"objRegistry.GetDWORDValue |
| form that people can read are generally this type. | | | | intValue |
| Entries are separated by spaces, commas, or | | | | Wscript.Echo strValueName & " = " & intValue |
| other marks. | | | | 'Delete DWORD valuestrKeyPath = "Registry |
| - Expandable String (REG_EXPAND_SZ): A | | | | Test"strValueName = "DWORD |
| variable-length data string. This data type includes | | | | Test"objRegistry.DeleteValue |
| variables that are resolved when a program or | | | | HKEY_CURRENT_USER,strKeyPath,strValueName |
| service uses the data. | | | | 'Set Multi-String valuestrKeyPath = "Registry |
| Option Explicit | | | | Test"strValueName = "Multi-String Test"arrValues |
| Const HKEY_CLASSES_ROOT = &H80000000 | | | | = |
| Const HKEY_CURRENT_USER = &H80000001 | | | | tringValue |
| Const HKEY_LOCAL_MACHINE = &H80000002 | | | | arrValues |
| Const HKEY_USERS = &H80000003 | | | | 'Get Multi-String valuestrKeyPath = "Registry |
| Const HKEY_CURRENT_CONFIG = &H80000005 | | | | Test"strValueName = "Multi-String |
| Dim strComputer | | | | Test"objRegistry.GetMultiStringValue |
| Dim objRegistry | | | | arrValues |
| Dim strKeyPath | | | | For Each strValue In arrValues |
| Dim strValueName | | | | Wscript.Echo strValueName & " = " & strValue |
| Dim strValue | | | | Next |
| Dim arrValues | | | | 'Delete Multi-String valuestrKeyPath = "Registry |
| Dim intValuestrComputer = "." | | | | Test"strValueName = "Multi-String |
| Set | | | | Test"objRegistry.DeleteValue |
| evel=impersonate}!" & strComputer & | | | | HKEY_CURRENT_USER,strKeyPath,strValueName |
| "rootdefault:StdRegProv") | | | | 'Set Expandable String valuestrKeyPath = |
| 'Create KeystrKeyPath = "Registry | | | | "Registry Test"strValueName = "Expandable String |
| Test"objRegistry.CreateKey | | | | Test"strValue = |
| HKEY_CURRENT_USER,strKeyPath | | | | "123"objRegistry.SetExpandedStringValue |
| 'Set String valuestrKeyPath = "Registry | | | | strValue |
| Test"strValueName = "String Test"strValue = | | | | 'Get Expandable String valuestrKeyPath = |
| "123"objRegistry.SetStringValue | | | | "Registry Test"strValueName = "Expandable String |
| strValue | | | | Test"objRegistry.GetExpandedStringValue |
| 'Get String valuestrKeyPath = "Registry | | | | strValue |
| Test"strValueName = "String | | | | Wscript.Echo strValueName & " = " & strValue |
| Test"objRegistry.GetStringValue | | | | 'Delete Expandable String valuestrKeyPath = |
| strValue | | | | "Registry Test"strValueName = "Expandable String |
| Wscript.Echo strValueName & " = " & strValue | | | | Test"objRegistry.DeleteValue |
| 'Delete String valuestrKeyPath = "Registry | | | | HKEY_CURRENT_USER,strKeyPath,strValueName |
| Test"strValueName = "String | | | | 'Delete KeystrKeyPath = "Registry |
| Test"objRegistry.DeleteValue | | | | Test"objRegistry.DeleteKey |
| HKEY_CURRENT_USER,strKeyPath,strValueName | | | | HKEY_CURRENT_USER,strKeyPath |
| 'Set Binary valuestrKeyPath = "Registry | | | | Set objRegistry = Nothing |
| Test"strValueName = "Binary Test"arrValues = | | | | Please note: |
| | | | The above script write, read and delete values in |
| arrValues | | | | the HKCU hive but can easily be modified to write |
| 'Get Binary valuestrKeyPath = "Registry | | | | to any of the registry hives. |
| Test"strValueName = "Binary | | | | |