Skip to content

fix(peek): set working directory when launching Open With#45393

Open
yeelam-gordon wants to merge 1 commit intomainfrom
issue/39305
Open

fix(peek): set working directory when launching Open With#45393
yeelam-gordon wants to merge 1 commit intomainfrom
issue/39305

Conversation

@yeelam-gordon
Copy link
Contributor

@yeelam-gordon yeelam-gordon commented Feb 5, 2026

Summary of the Pull Request

Fixes Peek's 'Open with' feature leaving the working directory in PowerToys folder instead of the file's directory. Applications launched via 'Open with' now correctly inherit the working directory of the selected file.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Problem

When using Peek's 'Open with' feature, the launched application would have its working directory set to PowerToys installation folder instead of the file's parent directory. This caused issues for applications that rely on working directory for relative paths.

Solution

Added WorkingDirectoryHelper.cs in src/modules/peek/Peek.Common/Helpers/ with:

  • OpenWithCorrectWorkingDirectory(string filePath, string? applicationPath) - Launches apps with correct working directory
  • OpenWithDialog(string filePath) - Opens Windows 'Open with' dialog with correct context

The helper sets ProcessStartInfo.WorkingDirectory to the file's parent directory before launching.

Validation Steps Performed

  1. Selected a file in File Explorer
  2. Opened Peek preview
  3. Used 'Open with' to launch an application
  4. Verified working directory matches file's parent folder

Fixes #39305

When using Peek's 'Open with' feature, the launched application now
receives the file's directory as its working directory instead of
the PowerToys installation folder.

Changes:
- Added WorkingDirectoryHelper class
- Sets WorkingDirectory to file's parent folder
- Applies to both direct open and 'Open with' dialog
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix issue #39305 where Peek's "Open With" feature launches applications with PowerToys' directory as the working directory instead of the file's directory. The PR adds a new helper class WorkingDirectoryHelper.cs with methods to launch applications with the correct working directory.

Changes:

  • Added WorkingDirectoryHelper.cs with two methods: OpenWithCorrectWorkingDirectory and ShowOpenWithDialog to handle launching applications with proper working directory settings

@yeelam-gordon yeelam-gordon changed the title fix(peek): set correct working directory for Open With fix(peek): set working directory when launching Open With Feb 5, 2026
Copy link
Contributor Author

@yeelam-gordon yeelam-gordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review - #45393

This PR adds WorkingDirectoryHelper.cs but does not integrate it with the existing Peek Open With flow. 2 High, 4 Medium issues found.

Copy link
Contributor Author

@yeelam-gordon yeelam-gordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Functionality][Medium] Added WorkingDirectoryHelper is not invoked by the current Peek Open With flow (TitleBar.LaunchDefaultAppButtonAsync still uses Launcher.LaunchFileAsync), so working directory behavior remains unchanged. Please wire OpenWithCorrectWorkingDirectory/ShowOpenWithDialog into the Open With path or replace the Launcher calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Peek's open with...leaves the launched applications working directory in Power Toys

1 participant