I have a batch file that creates a ma开发者_运维百科in folder and moves files & subfolders into it. I need the batch file to run every .REG file in the main folder.
I have my main folder set as a variable (it does not end in an ending slash): %folder%
I'm trying something like this, but this is only my second day writing batch scripts, so I don't know if my syntax is messed up or what.
for %%i in (%folder%\*.reg) do (regedit /s %%i)
I would greatly appreciate any help anyone can provide.
Thank you so much.
-Andrea
Your folder probably contains spaces in it, so you need to quote the %%i in the regedit part.
I tried for %i in (%folder%\*.reg) do (regedit /s %i)
(removed extra %) on Win2k8R2 and it behaved as expected. What version of Windows are you using? What error messages or bad behavior are you seeing?
I modified it a bit, and it works as expected like this:
for %%i in ("%~dp0"*.reg) do (regedit /s "%%i")
精彩评论