CMD doesn't restore title after last statement in a batch file #8756

Open
opened 2026-01-31 01:37:12 +00:00 by claunia · 0 comments
Owner

Originally created by @randomascii on GitHub (Jun 2, 2020).

Environment

Windows build number: Microsoft Windows [Version 10.0.18362.836]
Windows Terminal version (if applicable): 1.0.1401.0

Steps to reproduce

Create these two batch files and then run b1.bat:

b1.bat:
echo In b1
if 1 == 1 (
b2.bat
)

b2.bat:
echo In b2

Expected behavior

After the batch files stop running I expect the title of the running terminal, as shown in its tab, to return to its previous value, which defaults to "cmd".

Actual behavior

The title of the running terminal, as shown in its tab, is changed to b1.

The consequence of this is that if I run a long-running batch file and then go to another tab I cannot reliably use the title of the first tab to tell when the task has completed. This can be worked around using call followed by exit /b, but such workarounds should not be needed.

Here is an example of a workaround I added to Chrome's depot_tools:

https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2225340

Originally created by @randomascii on GitHub (Jun 2, 2020). # Environment ``` Windows build number: Microsoft Windows [Version 10.0.18362.836] Windows Terminal version (if applicable): 1.0.1401.0 ``` # Steps to reproduce Create these two batch files and then run b1.bat: b1.bat: echo In b1 if 1 == 1 ( b2.bat ) b2.bat: echo In b2 # Expected behavior After the batch files stop running I expect the title of the running terminal, as shown in its tab, to return to its previous value, which defaults to "cmd". # Actual behavior The title of the running terminal, as shown in its tab, is changed to b1. The consequence of this is that if I run a long-running batch file and then go to another tab I cannot reliably use the title of the first tab to tell when the task has completed. This can be worked around using call followed by exit /b, but such workarounds should not be needed. Here is an example of a workaround I added to Chrome's depot_tools: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2225340
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8756