新项递归注册表项



使用PowerShell,您可以运行这样的命令

ni c:/foo/bar -type directory

它将根据需要创建foobar。但是,如果您运行

ni hklm:software/classes/firefoxhtml/shell/edit/command -type directory

除最后一个密钥外的所有密钥都必须存在,否则将生成错误。PowerShell 能否根据需要生成父密钥?

我只是缺少-force参数

New-Item hklm:software/classes/firefoxhtml/shell/edit/command -Force

使用-Force还将删除密钥下的所有内容(如果它已经存在),因此更好的选择

if(!(Test-Path $path)){
    New-Item $path -Force;
}

最新更新