Load environment variables from a file
- This program is designed to be used in a batch script. (.bat .cmd)
- doesn't directly set the variable, but outputs the commands to do so.
for /f "delims=" %%k in ('loadenv.exe <cfg> <switches>') do ( %%k )
This is due to a limitation (security feature) in windows where a process cannot change another processes environment. so instead we use this as a tool for getting all environment vars and passing them into the calling environment.
for /f "delims=" %%k in ('loadenv.exe <cfg> <switches> 2^>nul') do ( %%k )
for /f "delims=" %%k in ('loadenv.exe <cfg> <switches> 2^>error.txt') do ( %%k )
; this is a comment
VAR=VAL
VAR=
- vars you want to expand must be enclosed in
%
VAR=%OTHER_VAR%
PREV_VAR=Testing
NEXT_VAR=%OTHER_VAR% 123
%NEXT_VAR%
will be set toTesting 123
- -q - Suppress all output except for errors.