Windows Terminal does not release folder handle when starting with 'Open in Terminal' #17644

Open
opened 2026-01-31 05:48:44 +00:00 by claunia · 0 comments
Owner

Originally created by @danielniccoli on GitHub (Jun 6, 2022).

Windows Terminal version

1.12.10983.0

Windows build number

22000.675

Other Software

No response

Steps to reproduce

  1. Open Windows Explorer.
  2. Navigate to a root folder of your liking e.g., C:\.
  3. Create a new folder C:\Test.
  4. Right-click the new folder and choose: Open in Terminal.
  5. Verify that the opened Terminal is at location C:\Test.
  6. Change to the parent directory.
  7. Try to remove the directory C:\Test you created earlier, either from within the Terminal, or in the Windows Explorer.

Expected Behavior

The directory should be deleted.

Actual Behavior

The directory cannot be deleted because it is being used by other processes.
When inspecting with procexp.exe, both processes, OpenConsole.exe, and WindowsTerminal.exe keep the file handles open, even after the terminal navigates outside the folder. Sometimes you can also find powershell.exe, or pwsh.exe keeping the handle.

grafik

During my tests, it also happened that procmon.exe reported handles by non-existing processes. I believe that happened when I closed the WindowsTerminal, that I initially opened, but still had a different Terminal open at a different location.

grafik

Only after closing the Terminal that was opened, the handle is released and the folder can be deleted.

Originally created by @danielniccoli on GitHub (Jun 6, 2022). ### Windows Terminal version 1.12.10983.0 ### Windows build number 22000.675 ### Other Software _No response_ ### Steps to reproduce 1. Open Windows Explorer. 2. Navigate to a root folder of your liking e.g., `C:\`. 3. Create a new folder `C:\Test`. 4. Right-click the new folder and choose: *Open in Terminal*. 5. Verify that the opened Terminal is at location `C:\Test`. 6. Change to the parent directory. 7. Try to remove the directory `C:\Test` you created earlier, either from within the Terminal, or in the Windows Explorer. ### Expected Behavior The directory should be deleted. ### Actual Behavior The directory cannot be deleted because it is being used by other processes. When inspecting with `procexp.exe`, both processes, `OpenConsole.exe`, **and** `WindowsTerminal.exe` keep the file handles open, even after the terminal navigates outside the folder. Sometimes you can also find `powershell.exe`, **or** `pwsh.exe` keeping the handle. ![grafik](https://user-images.githubusercontent.com/2971735/172236135-3be99785-1773-47d4-9839-90232eb0fc72.png) During my tests, it also happened that `procmon.exe` reported handles by non-existing processes. I believe that happened when I closed the WindowsTerminal, that I initially opened, but still had a different Terminal open at a different location. ![grafik](https://user-images.githubusercontent.com/2971735/172235703-89c7a4bb-15ba-4765-bd85-79a83b10f800.png) Only after closing the Terminal that was opened, the handle is released and the folder can be deleted.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 05:48:44 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17644