VBScript Scripting Techniques > Registry > WSH Shell
WSH Shell | |
---|---|
VBScript Code: | |
' Create a WSH Shell object: Set wshShell = CreateObject( "WScript.Shell" ) ' ' Create a new key: wshShell.RegWrite "HKCU\TestKey\", "" ' Create a new DWORD value: wshShell.RegWrite "HKCU\TestKey\DWordTestValue", 1, "REG_DWORD" ' Create a new subkey and a string value in that new subkey: wshShell.RegWrite "HKCU\TestKey\SubKey\StringTestValue", "Test", "REG_SZ" ' Read the values we just created: WScript.Echo "HKCU\TestKey\DWordTestValue = " _ & wshShell.RegRead( "HKCU\TestKey\DWordTestValue" ) WScript.Echo "HKCU\TestKey\SubKey\StringTestValue = """ _ & wshShell.RegRead( "HKCU\TestKey\SubKey\StringTestValue" ) & """" ' Delete the subkey and key and the values they contain: wshShell.RegDelete "HKCU\TestKey\SubKey\" wshShell.RegDelete "HKCU\TestKey\" ' Note: Since the WSH Shell has no Enumeration functionality, you cannot ' use the WSH Shell object to delete an entire "tree" unless you ' know the exact name of every subkey. ' If you don't, use the WMI StdRegProv instead. ' Release the object Set wshShell = Nothing |
|
Requirements: | |
Windows version: | any |
Network: | any |
Client software: | N/A |
Script Engine: | WSH |
Summarized: | Works in any Windows version. Can be used in *.vbs with CSCRIPT.EXE or WSCRIPT.EXE, not in HTAs. |
[Back to the top of this page] |
page last modified: 2016-09-19; loaded in 0.0021 seconds