Share this page 

Set an environment variable from a text file contentTag(s): Misc Prog HowTo

Let's say we have the following text file.


this is an interesting howto
This batch file will read the given file and set the environment variable content with the file content.


@echo off
SetLocal EnableDelayedExpansion
set content=
for /F "delims=" %%i in (howto.txt) do set content=!content!%%i
echo %content%
gives this output
> howto.cmd
this is an interesting howto