1

The text file will be having just one word("1234" or "password" ), now I'm looking for a way to give this content of the text file to an environment variable

2 Answers 2

4

If you only want to read one line you can also use set /p.

<myFile.txt set /p var=
echo %var%
Sign up to request clarification or add additional context in comments.

Comments

2

Use below for loop syntax. Replace filename with your filename, or environmental variable. If this code is supposed to be put inside a batch file, replace % with %%, as %%t.

for /F %t in (filename) Do (
    echo %t
    :: Do whatever else you want to do with %t
)

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.