How to read the content of a text file into an environment variable in a Windows batch file?
Posted: (EET/GMT+2)
Windows' default batch files (those .bat or .cmd files) do not directly support reading contents of a text file into memory. However, you can use environment variables for this, so that you can take a text file on disk, and assign its contents (not its filename) to an environment variable.
Here's how you would do this using the "set" command:
set /p myvariable= < inputfile.txt
This can be very handy at times. Happy scripting!