This page is edited from the 1cmdfaq.txt faq-file contained in
my tscmd.zip
command line interface (CLI) collection. That zipped file has much
additional material, including a number of detached .cmd script
files. It is recommended that you also get the zipped version as a
companion.
Please see "
The Description and
the Index page" for the conditions of usage and other such
information.
17} How can I avoid the potential "ECHO is off." in echoing %myvar%
Use a period right after the echo.
@echo off
setlocal
set myvar=This is a test
echo.%myvar%
set myvar=
echo.%myvar%
echo That's all
endlocal
Which gives
D:\TEST>cmdfaq
This is a test
That's all
Without the period (.) you'd get
D:\TEST>cmdfaq
This is a test
ECHO is off.
That's all
Of course, this always is valid
@echo off & setlocal enableextensions
set myvar=
echo myvar=%myvar%
set myvar=Hi there
echo myvar=%myvar%
endlocal & goto :EOF
C:\_D\TEST>cmdfaq
myvar=
myvar=Hi there
You might also find the information in the following items of interest:
item #040,
item #47,
item #51,
item #82,
item #89,
item #141.