2

I have a batch script to find an delete regedit key:

@for %%I in ("foo") do reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "%%~I" /f

I need to expand the search and removal of "foo" in other registry keys:

"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run"
"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"

How do I do it with a single command?

1 Answer 1

1

How do I do it with a single command?

Use brackets:

@echo off
setlocal enabledelayedexpansion
@for %%I in ("foo") do (
  reg delete "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run" /v "%%~I" /f
  reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "%%~I" /f
  REM add more here
  )
endlocal

Further Reading

1
  • exceptional. thanks a lot
    – acgbox
    Commented May 28, 2021 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .