Reputation: 2517
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
Upvotes: 1
Views: 871
Reputation: 82247
If you only want to read one line you can also use set /p
.
<myFile.txt set /p var=
echo %var%
Upvotes: 4
Reputation: 20980
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
)
Upvotes: 2