wt.exe startingDirectory argument fails with path containing spaces and a trailing backslash #23628

Closed
opened 2026-01-31 08:47:40 +00:00 by claunia · 5 comments
Owner

Originally created by @stuerp on GitHub (Sep 20, 2025).

Windows Terminal version

Preview_1.24.2372.0_x64

Windows build number

10.0.26100.4946

Other Software

PowerShell 7.5.3 as default profile

Steps to reproduce

Fails to set the starting directory (note the trailing backslash):

wt.exe --startingDirectory "c:\A\B B\"

Successfully sets the starting directory:

wt.exe --startingDirectory "c:\A\B B"

Expected Behavior

The starting directory should be set in both cases.

Actual Behavior

[error 2147942402 (0x80070002) when launching `B\']
The system cannot find the file specified.
Originally created by @stuerp on GitHub (Sep 20, 2025). ### Windows Terminal version Preview_1.24.2372.0_x64 ### Windows build number 10.0.26100.4946 ### Other Software PowerShell 7.5.3 as default profile ### Steps to reproduce Fails to set the starting directory (note the trailing backslash): `wt.exe --startingDirectory "c:\A\B B\"` Successfully sets the starting directory: `wt.exe --startingDirectory "c:\A\B B"` ### Expected Behavior The starting directory should be set in both cases. ### Actual Behavior ``` [error 2147942402 (0x80070002) when launching `B\'] The system cannot find the file specified. ```
claunia added the Needs-TriageIssue-Bug labels 2026-01-31 08:47:40 +00:00
Author
Owner

@marcotaranta commented on GitHub (Oct 8, 2025):

Hello, I'm tackling that issue.

@marcotaranta commented on GitHub (Oct 8, 2025): Hello, I'm tackling that issue.
Author
Owner

@DHowett commented on GitHub (Oct 15, 2025):

Right now the situation here isn't great, but the workaround we've generally recommended for anybody autogenerating paths for -d is to append a . instead. It's going to work on all versions of Terminal, whereas a fix we start rolling out tomorrow is only going to work on that version ;P

@DHowett commented on GitHub (Oct 15, 2025): Right now the situation here isn't great, but the workaround we've generally recommended for anybody autogenerating paths for `-d` is to append a `.` instead. It's going to work on _all versions of Terminal_, whereas a fix we start rolling out tomorrow is only going to work on that version ;P
Author
Owner

@DHowett commented on GitHub (Oct 15, 2025):

FWIW, it looks like this is a duplicate of #4571.

@DHowett commented on GitHub (Oct 15, 2025): FWIW, it looks like this is a duplicate of #4571.
Author
Owner

@stuerp commented on GitHub (Oct 16, 2025):

Right now the situation here isn't great, but the workaround we've generally recommended for anybody autogenerating paths for -d is to append a . instead. It's going to work on all versions of Terminal, whereas a fix we start rolling out tomorrow is only going to work on that version ;P

How is that a workaround? It only is when you know beforehand that the caller generates paths with a trailing backslash. Appending a '.' to "C:\A\B B" results in an invalid path.

@stuerp commented on GitHub (Oct 16, 2025): > Right now the situation here isn't great, but the workaround we've generally recommended for anybody autogenerating paths for `-d` is to append a `.` instead. It's going to work on _all versions of Terminal_, whereas a fix we start rolling out tomorrow is only going to work on that version ;P How is that a workaround? It only is when you know beforehand that the caller generates paths with a trailing backslash. Appending a '.' to "C:\A\B B" results in an invalid path.
Author
Owner

@DHowett commented on GitHub (Oct 17, 2025):

Sorry, I misremembered. Append \.. If the path ends with \, it becomes foo\\. (which is valid.) If it does not end with \, it becomes foo\..

@DHowett commented on GitHub (Oct 17, 2025): Sorry, I misremembered. Append `\.`. If the path ends with `\`, it becomes `foo\\.` (which is valid.) If it does not end with `\`, it becomes `foo\.`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23628