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

Open
opened 2026-01-31 05:33:51 +00:00 by claunia · 0 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:51 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17159