Creates a new key, adds another value-name to an existing key (and assigns it a value), or changes the value of an existing value-name.
|
---|
object.RegWrite(strName, anyValue [,strType]) |
Arguments
- object
WshShell object.
- strName
String value indicating the key-name, value-name, or value you want to create, add, or change.
- anyValue
The name of the new key you want to create, the name of the value you want to add to an existing key, or the new value you want to assign to an existing value-name.
- strType
Optional. String value indicating the value's data type.
Remarks
Example
The following code creates a key and two values, reads them, and deletes them.
Visual Basic Script | Copy Code |
---|
Dim WshShell, bKey
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell. RegWrite"HKCU\Software\ACME\FortuneTeller\", 1, "REG_BINARY"
WshShell. RegWrite"HKCU\Software\ACME\FortuneTeller\MindReader", "Goocher!", "REG_SZ"
bKey = WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\")
WScript.Echo WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\MindReader")
WshShell.RegDelete "HKCU\Software\ACME\FortuneTeller\MindReader"
WshShell.RegDelete "HKCU\Software\ACME\FortuneTeller\"
WshShell.RegDelete "HKCU\Software\ACME\" |
JScript | Copy Code |
---|
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\", 1, "REG_BINARY");
WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader", "Goocher!", "REG_SZ");
var bKey = WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\");
WScript.Echo (WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader"));
WshShell.RegDelete ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader");
WshShell.RegDelete ("HKCU\\Software\\ACME\\FortuneTeller\\");
WshShell.RegDelete ("HKCU\\Software\\ACME\\"); |
See Also