Reputation: 111
What is the correct syntax to delete registry keys when an asterisk is in the middle ot the registiry path, like this:
"Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shellex\
ContextMenuHandlers\SimpleShlExt\{45203D3B-3D73-4497-8AFE-D29950AC6C55}"
Upvotes: 0
Views: 439
Reputation: 25051
You can delete a registry key using Remove-Item. If you include no parameters when running Remove-Item
, your path value will automatically be assigned to the -Path
parameter. The -Path
parameter accepts wildcards, which includes *
. To treat wildcard characters as literals, you can use the -LiteralPath
parameter instead.
Remove-Item -LiteralPath 'HKLM:\SOFTWARE\Classes*\shellex\ContextMenuHandlers\SimpleShlExt{45203D3B-3D73-4497-8AFE-D29950AC6C55}'
The different registry hives are automatically mapped as PSDriveInfo
objects in your session. HKEY_LOCAL_MACHINE
has the drive name HKLM
. You interact with that drive just like any other mapped drive, i.e. where you could use "C:\Path"
, you could potentially use the syntax "HKLM:\Path"
.
Upvotes: 2