修复 PowerShell 命令 WorkingDirectory 参数处理,及优化部分命令#98
Merged
Jack251970 merged 3 commits intoJack251970:masterfrom Feb 24, 2026
Merged
修复 PowerShell 命令 WorkingDirectory 参数处理,及优化部分命令#98Jack251970 merged 3 commits intoJack251970:masterfrom
Jack251970 merged 3 commits intoJack251970:masterfrom
Conversation
修正了生成 PowerShell 命令时 WorkingDirectory 参数的逻辑,仅在 directory 非空且非空白时添加该参数,避免传递无意义的 $null,使命令更简洁且符合 PowerShell 规范。
将 EnhanceMenusDic.xml 中防火墙相关菜单项的命令由 cmd+netsh 替换为 PowerShell 脚本,提升规则操作的准确性和兼容性。同时优化英文菜单项描述,使其更符合表达习惯。
将“获取哈希值”菜单由单一命令改为多子菜单结构,支持 MD5、SHA1、SHA256、SHA384、SHA512 及全部算法选项。每项均调用 PowerShell 并以彩色高亮显示结果,提升交互体验和易用性,支持中英文多语言。
3 tasks
There was a problem hiding this comment.
Pull request overview
This pull request fixes a critical bug in PowerShell command generation where the WorkingDirectory parameter was being passed as $null, causing the "Restart Explorer" feature to fail. The PR also enhances the "Get Hash" menu by splitting it into individual submenu items for different hash algorithms with improved output formatting, and modernizes firewall rule management by migrating from netsh commands to PowerShell cmdlets.
Changes:
- Fixed WorkingDirectory parameter handling to omit the parameter when directory is null/empty/whitespace instead of passing
$null - Refactored "Get Hash" menu from a single command showing all algorithms to separate submenu items for MD5, SHA1, SHA256, SHA384, SHA512, and all algorithms
- Migrated firewall rule commands from cmd.exe with netsh to powershell.exe with NetFirewall cmdlets
- Updated English translations for firewall commands from "Not Allow" to "Block"
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| ContextMenuManager/Controls/ShellExecuteDialog.cs | Fixed WorkingDirectory parameter to only include it in PowerShell command when directory is not null/empty/whitespace, resolving the $null parameter error |
| ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml | Enhanced Get Hash menu structure with individual algorithm submenus, migrated firewall commands to PowerShell cmdlets, and improved English translations |
Comments suppressed due to low confidence (1)
ContextMenuManager/Controls/ShellExecuteDialog.cs:66
- In the else branch (for Windows versions before 10), the directory variable is passed directly to the VBScript ShellExecute call without checking if it's null or empty after attempting to derive it from the file path. If ObjectPath.GetFullFilePath fails to find the file path, and Path.GetDirectoryName returns null, this could result in passing a null directory to the VBScript. Consider adding a null check or default value handling for the directory in this branch as well.
else
{
arguments = arguments.Replace("\"", "\"\"");
return "mshta vbscript:createobject(\"shell.application\").shellexecute" +
$"(\"{fileName}\",\"{arguments}\",\"{directory}\",\"{verb}\",{windowStyle})(close)";
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#93