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