With PowerShell you can run a command like this
ni c:/foo/bar -type directory
and it will create foo
and bar
as necessary. However if you run
ni hklm:software/classes/firefoxhtml/shell/edit/command -type directory
all keys but the last must exist or an error will be generated. Can PowerShell generate the parent keys as needed?
One of the easiest ways to find registry keys and values is using the Get-ChildItem cmdlet. This uses PowerShell to get a registry value and more by enumerating items in PowerShell drives. In this case, that PowerShell drive is the HKLM drive found by running Get-PSDrive .
I was just missing the -force
parameter
New-Item hklm:software/classes/firefoxhtml/shell/edit/command -Force
Using -Force
will also remove everything under the key if it already exists so a better option would be
if(!(Test-Path $path)){
New-Item $path -Force;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With