When you set a environment variable cmd sort all the the environment variable block.
Because this, I think that if need concatenate a string using this:
Code: Select all
set "line="
set "line=%line%string1"
set "line=%line%string2"
set "line=%line%string3"
cmd do 4 enviroment block sort (using all the environment variable names).
I want for avoid this. Then I found a way for save variables without use a file, keeping it in memory, using doskey.
Look this code (I use none set command for the concatenation):
Code: Select all
@echo off
(doskey concat==)
for %%# in (
"this"
"is"
"a"
"string"
) do for /f "tokens=1* delims==" %%a in (
'doskey /macros ^| findstr "^concat="'
) do (doskey concat=%%b%%~#)
rem display result
doskey /macros | findstr "^concat="
pause