Supprimer registre key or value via a CMD script?

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Supprimer registre key or value via a CMD script?

Message par Clippy »

Comment edit an already-in-production `.cmd` script file, afin de 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, it is not working:

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

```

This method hasn't a fonctionné pour moi 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
]

```
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: Supprimer registre key or value via a CMD script?

Message par Clippy »

I would recommend using the **REG** command, rather than creating and importing .reg files.

```
reg delete "HKCU\Some\Registry\Path" /f

```

or

```
reg delete "HKLM\Some\Registry\Path" /f

```

These commands can be entered directly into the batch (`.cmd`) file.
Répondre

Revenir à « Personnalisation Windows »