executing all the .reg files from batch file

隐身守侯 提交于 2019-12-08 13:37:33

I think that you need a recursive for loop using the /R switch:

for /R "%folder%" %%i in (*.reg) do (regedit /s "%%i")

You didn't actually say what your problem was, so instead of fixing your script here's what I would have done:

@echo off
set folder=%~dp0
for /f "usebackq" %%i in (`dir /s /b *.reg`) do (
        regedit /s "%%i"
)

And the /s script on regedit is for silent mode. It tells regedit not to ask the user for confirmation with a dialog box. The for loop is what causes the batch file to loop through all subdirectories, not the /s switch on regedit.

From Microsoft's Knowledge Base:

[/s|-s]
When a filename is specified on the command line, this switch is used to 
suppress any informational dialog boxes that would normally be displayed.
This is useful when the Setup program for an application wants to execute
REGEDIT.EXE with a .REG file, but does not want the user to be confused by
any dialog boxes that are displayed.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!