Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Each line in input file.txt has two values separated by a space. Currently using:

for /F "tokens=1,2" %%i in (file.txt) do call :setvars %%i %%j

     set %1=%2
     set %3=%4
     set %4=%5


First line works perfectly and all other lines return that the syntax is incorrect. What do I need to do to process all of the lines?

share|improve this question

1 Answer 1


@echo off
for /f "tokens=* delims= " %%a in (test.txt) do (
    set /a N += 1
    set v!N! = %%a


test value
another yes

With these two files, the environment variables are set properly when test.bat is run. This can be verified by using the set command.

set output:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.