Windows – Delete registry key via CMD script

scriptingwindowswindows-registry

I'm want to edit an already production .cmd script file, to have the script delete a certain registry key in the Windows registry.

Firstly, is this even possible, and secondly (if that's not possible), could I create a .reg file and execute that file from with the .cmd file???

From within the .cmd script is not working:

del "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\CurrentVersion\SampleKey]"

This method hasn't worked for me either:

cmd "\\networkdrive\regfiles\deleteSampleKey.reg"

Then from within the reg file:

Windows Registry Editor Version 5.00
[
-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
]

NOTE: I am using Windows 2000 x86 Operating System. I'm not sure whether this will have any effect on how things work?

Best Answer

What about

 Reg Delete HKLM\SOFTWARE\Microsoft\CurrentVersion\SampleKey

?

Type

 reg Delete /? 

for more info