Export (0) Print
Expand All
Expand Minimize

Converting the Windows Script Host RegDelete Method

Windows PowerShell

Definition: Deletes a key or one of its values from the registry.


Need to delete a registry value? Hey, no problem; just use the Remove-ItemProperty cmdlet followed by two parameters: the registry path to the key where the value resides; and the –name parameter followed by the value you want to delete. You know, like this:

Remove-ItemProperty HKCU:\Software\Test -name NewValue

Removing a registry key is even easier; just call the Remove-Item cmdlet followed by the path to the key to be removed:

Remove-Item HKCU:\Software\Test

Of course, there is one catch here; unless the key is empty you’ll be presented with a confirmation message similar to this:

The item at HKCU:\Software\Test has children and the Recurse parameter was not specified. If you continue, all children  will be removed with the item. Are you sure you want to continue?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): n

Don’t like that confirmation message? Then just tack on the –recurse parameter, like so:

Remove-Item HKCU:\Software\Test -recurse

That will immediately delete the registry key, empty or not.

See conversions of other Windows Script Host methods and properties.
Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft