Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

push/pop echo state

121 views
Skip to first unread message

Václav Zeman

unread,
May 20, 2013, 5:38:20 AM5/20/13
to
Hi.

I would like to push/pop echo state similar to what `setlocal` and `endlocal` does for environment variables. Is this reasonably easily possible?

--
VZ

Todd Vargo

unread,
May 20, 2013, 2:43:18 PM5/20/13
to
On 5/20/2013 5:38 AM, V�clav Zeman wrote:
> Hi.
>
> I would like to push/pop echo state similar to what `setlocal` and `endlocal` does for environment variables. Is this reasonably easily possible?
>

You can launch a child CMD instance, change the ECHO state to suit that
instance and when it exits the ECHO state of the original instance will
be restored. Here are two batches to demonstrate.

::This is Demo1.cmd
@echo off
echo this is %~nx0 and ECHO is OFF
cmd /c Demo2
echo control returned to %~nx0 but ECHO is still off
pause



::This is Demo2.cmd
echo control passed to %~nx0 and ECHO is ON
dir
echo this is %~nx0 and ECHO is ON

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Stanley Daniel de Liver

unread,
May 20, 2013, 4:49:32 PM5/20/13
to
On Mon, 20 May 2013 19:43:18 +0100, Todd Vargo <tlv...@sbcglobal.netz>
wrote:

> On 5/20/2013 5:38 AM, Václav Zeman wrote:
>> Hi.
>>
>> I would like to push/pop echo state similar to what `setlocal` and
>> `endlocal` does for environment variables. Is this reasonably easily
>> possible?
>>
>
> You can launch a child CMD instance, change the ECHO state to suit that
> instance and when it exits the ECHO state of the original instance will
> be restored. Here are two batches to demonstrate.
>
> ::This is Demo1.cmd
> @echo off
> echo this is %~nx0 and ECHO is OFF
> cmd /c Demo2
> echo control returned to %~nx0 but ECHO is still off
> pause
>
>
>
> ::This is Demo2.cmd
> echo control passed to %~nx0 and ECHO is ON
> dir
> echo this is %~nx0 and ECHO is ON
>


or set a variable


rem on
echo on
set noecho=off
...


rem off
echo off
set noecho=on


rem toggle
echo %noecho%
if %noecho%==off set noecho=tmp
if %noecho%==on set noecho=off
if %noecho%==tmp set noecho=on


(untested)


--
It's a money /life balance.

jeb

unread,
Jun 5, 2013, 5:10:44 AM6/5/13
to
Hi,

it's a bit tricky to get the current echo state.
It can be done with a temp file.

Try a look at "restore the previous echo status"
http://stackoverflow.com/a/9594675/463115
0 new messages