samanosuke
samanosuke

Reputation: 13

Powershell insert default registry name without quotes

I'm trying to add an application in the context menu using Powershell. When I'm using the command below to add the registry Expandable String, the name Default aka @ is inserted between quotes but it should be without.

[Microsoft.Win32.Registry]::SetValue("$hcrAPP\shell\$flyout\command", "@", "$appPath\$appVer\app\bin\app.exe $userDir\$app", Microsoft.Win32.RegistryValueKind]::ExpandString)

Result: "@"=hex(2):43,00,3a,...

Expected Result: @=hex(2):43,00,3a,...

Upvotes: 1

Views: 277

Answers (1)

js2010
js2010

Reputation: 27606

Note

A registry key can have one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To set this unnamed value, specify either null or the empty string ("") for name.

https://learn.microsoft.com/en-us/dotnet/api/microsoft.win32.registrykey.setvalue?view=netframework-4.8

Upvotes: 1

Related Questions