powershellregistry

How can I get and change the Value of the "(Standard)" key in the Registry with Powershell


I need to write a Script to change the Value of the (Standard) Key located in the Registry under:

REGISTRY::HKEY_CLASSES_ROOT\http\shell\open\command

I just cant get anything to work, everything i tried gives me the same response.

The Closest i've been is probably the following Code (was searching for a Solution Online):

$keypath = 'REGISTRY::HKEY_CLASSES_ROOT\http\shell\open\command\'
(Get-ItemProperty -Path $keypath -Name '(Standard)').'(Standard)'

But all I get back from it is:

Property (Standard) does not exist at path HKEY_CLASSES_ROOT\http\shell\open\command.

even though it clearly does exists. I assume im doing something clearly wrong, I tried searching for a solution and all I found was the code above.

Any Ideas?


Solution

  • Whereas the .NET APIs represent the unnamed default value as the empty string ('' or "" in PowerShell), PowerShell's registry provider uses '(default)' (invariably; that is, this string is not localized according the Windows display language, whereas it is in Registry Editor, for instance):

    $keypath = 'REGISTRY::HKEY_CLASSES_ROOT\http\shell\open\command\'
    
    # GET the data of the unnamed default value.
    # NOTE: Reports an *error* if the unnamed value doesn't exist.
    Get-ItemPropertyValue -Path $keypath -Name '(default)'
    
    # SET the data of the unnamed default value - REQUIRES ELEVATION
    Set-ItemProperty -Path $keypath -Name '(default)' -Value 'new value'
    

    Note: