Search notes:

Windows registry structure: value

Writing a value to the registry with reg in a console

In a console (cmd.exe or PowerShell), a value can be written to the registry with reg add /v ….
In PowerShell, a value can be created or modified with set-itemProperty.

PowerShell's representation of a registry value

In PowerShell, a registry value is represented by an itemProperty.

Querying a key

An existing value, for example the value of PATH in the registry key HKCU:\Environment, can be queried like so:
PS C:\> get-itemProperty HKCU:\Environment PATH
Unfortunately, this also prints varios PS* members like PSPath etc:
Path         : C:\Users\Rene\bin/scripts;…
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Environment
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER
PSChildName  : Environment
PSDrive      : HKCU
PSProvider   : Microsoft.PowerShell.Core\Registry
Therefore, get-itemPropertyValue seems to be the better approach:
PS C:\> get-itemPropertyValue HKCU:\Environment PATH

Creating a new value

Similarly, aew registry value can be created with new-itemProperty cmdLet:
PS C:\> $null = new-itemProperty HKCU:\Environment keyName -value 42

Dropping the value again

In PowerShell, a value can be deleted from a registry key with remove-itemProperty.
PS C:\> remove-itemProperty HKCU:\Environment keyName

See also

default value
Windows registry: tree structure

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1758201037, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/registry/tree-structure/value(85): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78