Cannot rename/delete the folder that the Terminal was initially opened in #17162

Closed
opened 2026-01-31 05:33:54 +00:00 by claunia · 2 comments
Owner

Originally created by @mariusgreuel on GitHub (Apr 5, 2022).

Windows Terminal version

1.12.10732.0

Windows build number

10.0.19044.1620

Other Software

No response

Steps to reproduce

  • Use Windows Explorer to create a new empty folder.
  • Open a terminal by typing wt in the address bar of Windows Explorer (here inside D:\test).
Microsoft Windows [Version 10.0.19044.1620]
(c) Microsoft Corporation. All rights reserved.

D:\test>cd ..

D:\>rmdir test
The process cannot access the file because it is being used by another process.

Expected Behavior

When I do the same thing using cmd.exe, I can delete the folder:

Microsoft Windows [Version 10.0.19044.1620]
(c) Microsoft Corporation. All rights reserved.

D:\test>cd ..

D:\>rmdir test

D:\>

Actual Behavior

It seems that Windows Terminal permanently keeps an open handle to the initial directory the terminal was opened in. This prevents one from renaming/deleting/... the directory from within the terminal. My expectation is that the terminal only has an open handle to the directory it is currently at.

Process Explorer confirms that after changing directories, there are still two open handles in WindowsTerminal.exe and OpenConsole.exe.

Originally created by @mariusgreuel on GitHub (Apr 5, 2022). ### Windows Terminal version 1.12.10732.0 ### Windows build number 10.0.19044.1620 ### Other Software _No response_ ### Steps to reproduce - Use Windows Explorer to create a new empty folder. - Open a terminal by typing `wt` in the address bar of Windows Explorer (here inside D:\test). ``` Microsoft Windows [Version 10.0.19044.1620] (c) Microsoft Corporation. All rights reserved. D:\test>cd .. D:\>rmdir test The process cannot access the file because it is being used by another process. ``` ### Expected Behavior When I do the same thing using `cmd.exe`, I can delete the folder: ``` Microsoft Windows [Version 10.0.19044.1620] (c) Microsoft Corporation. All rights reserved. D:\test>cd .. D:\>rmdir test D:\> ``` ### Actual Behavior It seems that Windows Terminal permanently keeps an open handle to the **initial** directory the terminal was opened in. This prevents one from renaming/deleting/... the directory from within the terminal. My expectation is that the terminal only has an open handle to the directory it is currently at. Process Explorer confirms that after changing directories, there are still two open handles in `WindowsTerminal.exe` and `OpenConsole.exe`.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 05:33:54 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Apr 5, 2022):

Thanks for the suggestion! This is actually already being tracked by another issue on our repo - please refer to #5506 for more discussion.

/dup #5506

@zadjii-msft commented on GitHub (Apr 5, 2022): Thanks for the suggestion! This is actually already being tracked by another issue on our repo - please refer to #5506 for more discussion. /dup #5506
Author
Owner

@ghost commented on GitHub (Apr 5, 2022):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Apr 5, 2022): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17162