Skip to content

fix: 使用 UseShellExecute 打开目录 - #3385

Merged
Hill23333 merged 1 commit into
devfrom
fix/3379
Jul 13, 2026
Merged

fix: 使用 UseShellExecute 打开目录#3385
Hill23333 merged 1 commit into
devfrom
fix/3379

Conversation

@LuLu-ling

@LuLu-ling LuLu-ling commented Jul 12, 2026

Copy link
Copy Markdown
Member

close #3379

Summary by Sourcery

Bug Fixes:

  • 在为现有目录路径启动进程时强制使用 shell 执行,以正确打开该文件夹,而不是尝试将其作为可执行文件运行。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Force shell execution when starting a process for an existing directory path to correctly open the folder instead of attempting to run it as an executable.

@LuLu-ling
LuLu-ling requested a review from a team July 12, 2026 01:44
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: XS PR 大小评估:微型 labels Jul 12, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor
审查者指南(在小型 PR 上折叠)

审查者指南

通过在目标路径为目录时设置 UseShellExecute,确保在启动进程以打开路径时,目录始终通过 shell 打开,同时保留现有的管理员权限提升行为。

目录 shell 执行的进程启动流程图

flowchart TD
    A[startProcess path is passed] --> B[Create ProcessStartInfo psi]
    B --> C{isAdmin}
    C -->|true| D[psi.UseShellExecute = true]
    D --> E[psi.Verb = runas]
    C -->|false| F[no admin changes]
    E --> G{Directory.Exists path}
    F --> G
    G -->|true| H[psi.UseShellExecute = true]
    G -->|false| I[leave psi.UseShellExecute as is]
    H --> J[Process.Start psi]
    I --> J
Loading

文件级变更

变更 详情 文件
确保当目标存在且为目录时,通过启用 UseShellExecute,使目录路径通过 shell 打开。
  • 在启动进程之前添加一个 Directory.Exists(path) 检查。
  • 当路径为目录时,将 psi.UseShellExecute = true,以允许通过 shell 正确打开文件夹。
  • 保留现有逻辑:在请求提升权限时启用 UseShellExecute 并设置 Verb="runas"。
PCL.Core/Utils/OS/ProcessInterop.cs

与关联 Issue 的对照评估

Issue 目标 是否解决 说明
#3379 修复在自定义主页上点击文件夹按钮(例如“Mod文件夹”)时,无法打开目标目录而是显示错误的问题,确保可以从 C# 启动器/自定义主页正确打开目录。

可能相关的 Issue


技巧与命令

与 Sourcery 交互

  • 触发新审查: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 通过回复某条审查评论,让 Sourcery 从中创建一个 issue。你也可以在审查评论下回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文的任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来在任意时间(重新)生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide,即可在任意时间(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理了所有评论且不想再看到它们,这会非常有用。
  • 取消所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,即可取消所有现有的 Sourcery 审查。尤其适用于你想从头开始一次新的审查时——别忘了再评论 @sourcery-ai review 来触发新审查!

自定义你的体验

访问你的 仪表盘 以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures that when starting a process to open a path, directories are always opened via the shell by setting UseShellExecute when the target path is a directory, in addition to the existing admin-elevation behavior.

Flow diagram for process start with directory shell execution

flowchart TD
    A[startProcess path is passed] --> B[Create ProcessStartInfo psi]
    B --> C{isAdmin}
    C -->|true| D[psi.UseShellExecute = true]
    D --> E[psi.Verb = runas]
    C -->|false| F[no admin changes]
    E --> G{Directory.Exists path}
    F --> G
    G -->|true| H[psi.UseShellExecute = true]
    G -->|false| I[leave psi.UseShellExecute as is]
    H --> J[Process.Start psi]
    I --> J
Loading

File-Level Changes

Change Details Files
Ensure directory paths are opened via the shell by enabling UseShellExecute when the target exists as a directory.
  • Add a Directory.Exists(path) check before starting the process.
  • Set psi.UseShellExecute = true when the path is a directory to allow proper shell-based opening of folders.
  • Keep existing logic that enables UseShellExecute and sets Verb="runas" when elevation is requested.
PCL.Core/Utils/OS/ProcessInterop.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#3379 Fix the bug where clicking a folder button (e.g., 'Mod文件夹') on the custom homepage fails to open the target directory and instead shows an error, ensuring directories can be opened correctly from the C# launcher/custom homepage.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - 我已经审阅了你的更改,一切看起来很棒!


Sourcery 对开源项目是免费的——如果你喜欢我们的审查,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进审查质量。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@pcl-ce-automation pcl-ce-automation Bot added 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels Jul 13, 2026
@Hill23333
Hill23333 merged commit 0fe4d69 into dev Jul 13, 2026
3 checks passed
@pcl-ce-automation pcl-ce-automation Bot added 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线 and removed 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 labels Jul 13, 2026
@LuLu-ling
LuLu-ling deleted the fix/3379 branch July 15, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS PR 大小评估:微型 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C#]: 无法于自定义主页打开特定文件夹

3 participants