The following seems to work fine in Windows 11 and should work in prior OS's. Later (in the same cmd file) you can say @echo %oldecho%
@echo > %TMP%\echo.tmp
@for /f "tokens=3 delims=. " %%e in (%TMP%\echo.tmp) do @set oldecho=%%e
@del %TMP%\echo.tmp
@echo was %oldecho%