Automatic network drive mapping when opening CMD from UNC path #23769

Closed
opened 2026-01-31 08:51:58 +00:00 by claunia · 2 comments
Owner

Originally created by @fowl2 on GitHub (Nov 2, 2025).

Description of the new feature

It'd be great if when opening a terminal from a UNC path, a free drive letter was automatically mapped and when no longer in use it was automatically unmapped.

Currently the easiest way to do this is copy+pasting the path and using pushd, thenpopd if I remember when done to unmap.

Extra credit: notification bar to show that it's been mapped.

Current behavior:

  1. Have "Command Prompt" set as default profile in Windows Terminal
  2. Browse to a UNC path (\\servername\sharename\) in File Explorer
  3. Right click the background or a folder and select "Open in Terminal"

Output

'\\servername\sharename\path\to\directory'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
Microsoft Windows [Version 10.0.26100.6899]
(c) Microsoft Corporation. All rights reserved.

C:\Windows>

Proposed technical implementation details

For finding a free drive letter and mapping see how pushd does it?

For automaticlly unmapping, Maybe Windows has a "unmap on last close" flag? Otherwise just make an attempt when the terminal closes. I guess you could show a notification bar if it fails with a retry button.

Originally created by @fowl2 on GitHub (Nov 2, 2025). ### Description of the new feature It'd be great if when opening a terminal from a UNC path, a free drive letter was automatically mapped and when no longer in use it was automatically unmapped. Currently the easiest way to do this is copy+pasting the path and using `pushd`, then`popd` if I remember when done to unmap. Extra credit: notification bar to show that it's been mapped. ### Current behavior: 1. Have "Command Prompt" set as default profile in Windows Terminal 2. Browse to a UNC path (`\\servername\sharename\`) in File Explorer 3. Right click the background or a folder and select "Open in Terminal" #### Output ``` '\\servername\sharename\path\to\directory' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory. Microsoft Windows [Version 10.0.26100.6899] (c) Microsoft Corporation. All rights reserved. C:\Windows> ``` ### Proposed technical implementation details For finding a free drive letter and mapping see how `pushd` does it? For automaticlly unmapping, Maybe Windows has a "unmap on last close" flag? Otherwise just make an attempt when the terminal closes. I guess you could show a notification bar if it fails with a retry button.
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 08:51:58 +00:00
Author
Owner

@DHowett commented on GitHub (Nov 5, 2025):

Thanks for the request! Honestly, I'm wary of us touching global system state--even for the duration of a single process--to work around a fairly narrow issue in a shell we're not intending on doing any new work on. I wouldn't ship that. Even so, I appreciate your plight.

@DHowett commented on GitHub (Nov 5, 2025): Thanks for the request! Honestly, I'm wary of us touching global system state--even for the duration of a single process--to work around a fairly narrow issue in a shell we're not intending on doing any new work on. I wouldn't ship that. Even so, I appreciate your plight.
Author
Owner

@fowl2 commented on GitHub (Nov 8, 2025):

Apparently mapped drives are per logon session, not global, but I completely understand. :)

Is it possible to pass the launched path to a profile? Ie. so I can hack up cmd /k popd "$magic"

@fowl2 commented on GitHub (Nov 8, 2025): Apparently [mapped drives are per logon session](https://learn.microsoft.com/en-us/windows/win32/services/services-and-redirected-drives), not global, but I completely understand. :) Is it possible to pass the launched path to a profile? Ie. so I can hack up `cmd /k popd "$magic"`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23769