0

I am trying to write a batch file to run through a list of domains and then use each on as a variable and then run a reg export on these like below:-

for /f "delims=" %%x in (domains.txt) do set Domain=%%x
GOTO :ExportReg 

:ExportReg
reg export HKEY_LOCAL_MACHINE\SOFTWARE\Ipswitch\IMail\Domains\%Domain% C:\export-%Domain%.txt
echo %%Domain%%

:End

but this just tries to output it all to the same file, causing overwrite errors

so it outputs as c:\export-domain.com.txt then the next one is say domain.co.uk but it tries to write it to domain.com.txt again.

1 Answer 1

2

You initial code will only every process the last domain in your domains.txt file. I would think you would want to process all domains. Would be much easier to do everything within the FOR command.

for /f "delims=" %%x in (domains.txt) do (
    reg export HKEY_LOCAL_MACHINE\SOFTWARE\Ipswitch\IMail\Domains\%%x C:\export-%%x.txt
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.