WR7500
WR7500

Reputation: 449

FOR loop for iterating through Registry hives

I'm working on a script to modify multiple registry keys at the same time. I'm trying to find a way to iterate through the sub-folders under a single registry hive, and run a specific command for each one found. The hive structure looks something like this:

HKLM
    -Blah
        -BLahBlah
            -Databases
                -DB1
                -DB2
                -DB3

What I want to do is basically set a new variable for the DB name, run a script for that specific folder, then move on to the next.

Upvotes: 1

Views: 671

Answers (1)

npocmaka
npocmaka

Reputation: 57262

With REG command you can query or edit registry entries. To process them one by one you can use FOR command:

for /f "tokens=*" %%# in ('reg query HKEY_LOCAL_MACHINE\BLAH\Databases') do echo %%#

Upvotes: 2

Related Questions