Starting directory doesn't take effect #18869

Closed
opened 2026-01-31 06:26:44 +00:00 by claunia · 1 comment
Owner

Originally created by @gyorokpeter on GitHub (Nov 11, 2022).

Windows Terminal version

1.15.2875.0

Windows build number

10.0.22621.819

Other Software

N/A

Steps to reproduce

Go to Settings -> Command Prompt, change Starting Directory from the default (%USERPROFILE%) to something else (e.g. D:\)
Press Windows+R, type cmd

Expected Behavior

The command prompt should open in the directory specified in the settings (D:\ in the above example).

Actual Behavior

The command prompt still opens in the default default directory (C:\Users\<my user name>).

Originally created by @gyorokpeter on GitHub (Nov 11, 2022). ### Windows Terminal version 1.15.2875.0 ### Windows build number 10.0.22621.819 ### Other Software N/A ### Steps to reproduce Go to Settings -> Command Prompt, change Starting Directory from the default (`%USERPROFILE%`) to something else (e.g. `D:\`) Press Windows+R, type `cmd` ### Expected Behavior The command prompt should open in the directory specified in the settings (`D:\` in the above example). ### Actual Behavior The command prompt still opens in the default default directory (`C:\Users\<my user name>`).
Author
Owner

@zadjii-msft commented on GitHub (Nov 11, 2022):

Yep, this is by design.

When you launch a Command Prompt tab in the Terminal, Terminal is in control of starting the cmd process, and can tell the OS what starting directory to create the process in.

When you launch cmd.exe directly, it starts before the Terminal does, so cmd already has a working directory (in this case, %userprofile%). It then gets attached to a Terminal window, but there's nothing the Terminal can do at this point to change CMD's CWD.

@zadjii-msft commented on GitHub (Nov 11, 2022): Yep, this is by design. When you launch a Command Prompt tab in the Terminal, Terminal is in control of starting the `cmd` process, and can tell the OS what starting directory to create the process in. When you launch `cmd.exe` directly, it starts before the Terminal does, so `cmd` already has a working directory (in this case, `%userprofile%`). It then gets attached to a Terminal window, but there's nothing the Terminal can do at this point to change CMD's CWD.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18869