Skip to content

Batch activators unexpectedly turn echo off for subsequent commands #96894

Closed

Description

@pawelszramowski

Bug report

Consider the following batch script:

python -m venv venv
CALL venv\Scripts\activate.bat
REM spam
CALL deactivate.bat
REM eggs

The expected output is:

W:\>python -m venv venv

W:\>CALL venv\Scripts\activate.bat

(venv) W:\>REM spam

(venv) W:\>CALL deactivate.bat

W:\>REM eggs

The actual output is:

W:\>python -m venv venv

W:\>CALL venv\Scripts\activate.bat

This is caused by @echo off at the beginning of both scripts that need to be undone after calling them:

python -m venv venv
CALL venv\Scripts\activate.bat
@ECHO ON
REM spam
CALL deactivate.bat
@ECHO ON
REM eggs

Your environment

  • CPython versions tested on: Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]

Linked PRs

Activity

  1. eryksun commented on Sep 17, 2022

    @eryksun
    Contributor

    If echo off isn't used, then individual statements have to be prefixed with @ to prevent echoing them. I just implemented this for the new versions of "activate.bat" and "deactivate.bat" that were proposed in issue #88706. Note that ending with echo on would be just as bad, since the caller may have it off. I haven't seen a way to detect the current echo state that doesn't involve ugly hacks such as writing to a temporary file.

  2. added a commit that references this issue on Apr 13, 2026
  3. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions