WshShell.RegWrite

Write a value to the Registry

Syntax 
      WshShell.RegWrite strRegName, anyValue, [strType]

Arguments:

         strRegName : 
         To set a key instead of a value terminate strRegName 
         with a backslash character \

         strRegName must start with one of

         HKEY_CURRENT_USER  or HKCU
         HKEY_USERS         
         HKEY_LOCAL_MACHINE or HKLM
         HKEY_CLASSES_ROOT  or HKCR
         HKEY_CURRENT_CONFIG

         strType :
         The data type can be optionally specified as one of
         REG_SZ, REG_EXPAND_SZ, (String values)
         REG_DWORD  (convert to Integer value)
         REG_BINARY (Integer value)

When you specify a key-name (as opposed to a value-name),
RegRead returns the default value. 

Examples

Hide hidden and system files in Windows Explorer:

Set WshShell = CreateObject("WScript.Shell")
myKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"
WshShell.RegWrite myKey,0,"REG_DWORD"
Set WshShell = Nothing

Display hidden and system files in Windows Explorer:

Set WshShell = CreateObject("WScript.Shell")
myKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"
WshShell.RegWrite myKey,1,"REG_DWORD"
Set WshShell = Nothing

"Nothing is permanent" - Buddha

Related:
Registry, delete - WshShell.RegDelete
Registry, read - WshShell.RegRead
Equivalent Windows CMD command: REG - Read, Set or Delete registry keys and values



Back to the Top

Simon Sheppard
SS64.com