I am trying to add a new item to the registry. I have done this in the past. I am getting a vague error.
Normally I use a command like this:
One thing that is different about the new item is that it is at the root level. That is, it is immediately after the HKLM.
Here is a command that works (well, there is no error, and I can use get-item on the path in PowerShell):
new-item -path HKEY_LOCAL_MACHINE\TempHive\Software\Microsoft\Windows\CurrentVersion4\Explorer33 -Type File -Force
There is no colon “:” in the above command. HKEY_LOCAL_MACHINE is spelled out.
Here is a command that does not work:
new-item -path HKLM:\TempHive\software\microsoft\windows\CurrentVersion4\Explorer23 -Type File -force
I get this error: “new-item: The parameter is incorrect…IOException…”
I cannot even get HKLM:\temphive to be created. I can create new registry entries if they are deep in a path that is already in existence. Ostensibly colons in new-item commands (e.g., new-item -path HKLM:\software\microsoft) don’t necessarily cause new-item commands to fail – as long as the item being created is in a path that already exists.
If there is no colon with a new-item command, I’ve noticed that the command seems to work as an interactive PowerShell command. However, when I look into Regedit (the GUI application), I see no evidence that the command worked. When there is a colon in the command, as far as the interactive PowerShell prompt goes, everything seems to work, I find that in regedit I do see evidence of the command having worked.
My main question is how do I create HKLM:\temphive? My other questions are, why do commands seem to work but do not appear in Regedit? Are colons necessary in the HKLM:\path[ syntax with the new-item command?