更新时间:2023-11-18 22:30:34
您需要做两件事.首先你需要得到一个可写的 RegistryKey
对象,否则你无论如何都不能修改任何东西.其次,直接在 RegistryKey
对象上使用 CreateSubKey
方法.
You need to do two things. First you need to get a writable RegistryKey
object, otherwise you can't modify anything anyway. Second, use the CreateSubKey
method on the RegistryKey
object directly.
$writable = $true
$key = (get-item HKLM:\).OpenSubKey("SOFTWARE", $writable).CreateSubKey("C:/test")
$key.SetValue("Item 1", "Value 1")
创建键后,您可以使用结果对象向其添加值.
After you create the key you use the resulting object to add values to it.