Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

powershell removing a specific registry key

Tags:

powershell

I am new to PowerShell and I am trying to remove a specific value from the run registry key. I am using the remove-item command, however, I don't see a switch to specify a single value. I don't want to remove the entire key, just one value.

For reference the batch equivalent of what I am trying to do:

reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v SunJavaUpdateSched /f
like image 933
user2804597 Avatar asked Sep 22 '13 16:09

user2804597


People also ask

How do I delete a specific registry key?

From the left pane in Registry Editor, drill down until you locate the registry key you want to delete or the key that contains the registry value you want to remove. You can't delete registry hives, the top-level keys you see in the editor. Once found, right-click or tap-and-hold on it and choose Delete.

Can you use PowerShell to edit registry?

You can still use other tools you already have available to perform filesystem copies. Any registry editing tools—including reg.exe , regini.exe , regedit.exe , and COM objects that support registry editing, such as WScript. Shell and WMI's StdRegProv class can be used from within Windows PowerShell.

How do I change registry keys in PowerShell?

It is easy to change add registry keys and values. You can use the New-Item cmdlet to create any key in any registry hive. Once you create the key, you can use New-ItemProperty to set a registry value entry.

How do I list registry keys in PowerShell?

One of the easiest ways to find registry keys and values is using the Get-ChildItem cmdlet. This uses PowerShell to get a registry value and more by enumerating items in PowerShell drives.


2 Answers

Remove-ItemProperty -Name 'nameofkeyentry' -Path 'pathtothekey'

For example the key 'HKCU:\Accessibility\AudioDescription' has 3 values


(Default) REG_SZ (value not set)
Locale    REG_SZ [blank]
On        REG_SZ 0

Suppose we would like to remove the 3rd value 'On' - we would do so as follows

Remove-ItemProperty -Name 'On' -Path 'HKCU:\Accessibility\AudioDescription'

note HKCU stands for HKEY_CURRENT_USER, each root is abbreviated intuitively the same way (e.g. HKEY_CLASSES_ROOT = HKCR:\, etc)

like image 105
TheFallenTech Avatar answered Sep 24 '22 04:09

TheFallenTech


use the cmdlet remove-itemproperty

like image 34
Tekno Sal Avatar answered Sep 22 '22 04:09

Tekno Sal