0

I'm trying to write a small batch script that is supposed to change some registry entries.

Now to do that from the command line one would use the reg add command. And when the specified registry key already exists it asks to overwrite the value.

For example reg add "HKCU\Control Panel\Colors" /v Background /t REG_SZ /d "120 0 0" yields Value Background exists, overwrite(Yes/No)? and only if I press y the command completes.

It does the same when the command is issued from a batch script. Since I would like the process to be automated and no further user input to be required I would like to remove the confirmation request. So is it possible to run this command non-interactively?

Owl Surojit
  • 173
  • 1
  • 10
  • 1
    Open a Command Prompt window, type `Reg Add /?` and press the enter key. The output clearly shows `/F` with the description, `Force overwriting the existing registry entry without prompt`. Given that, I'd suggest you change your command to `@"%__AppDir__%reg.exe" Add "HKCU\Control Panel\Colors" /V Background /D "120 0 0" /F > NUL`. _(The `> NUL` is to hide any 'successful' messages being printed to the console)_. – Compo Apr 07 '20 at 10:48
  • Thanks a lot, that solved my problem – Owl Surojit Apr 07 '20 at 16:33

1 Answers1

1

You can either use the /F flag as mentioned by Compo in the comments, or you can use a .reg file and start it in silent mode:

start regedit /s "C:\path\to\regfile.reg"
GChuf
  • 1,135
  • 1
  • 17
  • 28