For a legacy application, I need to create a registry key with a name in the format c:/foo/bar/baz
. (Note: forward slashes, not backslashes.) To be clear: tha
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.