From aa8eb9c257c9297f547df30b6c9e50f142c7cb0d Mon Sep 17 00:00:00 2001
From: CMJNB <53365071+CMJNB@users.noreply.github.com>
Date: Tue, 24 Feb 2026 01:51:09 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20PowerShell=20=E5=91=BD?=
=?UTF-8?q?=E4=BB=A4=20WorkingDirectory=20=E5=8F=82=E6=95=B0=E5=A4=84?=
=?UTF-8?q?=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
修正了生成 PowerShell 命令时 WorkingDirectory 参数的逻辑,仅在 directory 非空且非空白时添加该参数,避免传递无意义的 $null,使命令更简洁且符合 PowerShell 规范。
---
ContextMenuManager/Controls/ShellExecuteDialog.cs | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/ContextMenuManager/Controls/ShellExecuteDialog.cs b/ContextMenuManager/Controls/ShellExecuteDialog.cs
index c502ac0..4c3ee2e 100644
--- a/ContextMenuManager/Controls/ShellExecuteDialog.cs
+++ b/ContextMenuManager/Controls/ShellExecuteDialog.cs
@@ -29,7 +29,7 @@ protected override bool RunDialog(IntPtr hwndOwner)
public static string GetCommand(string fileName, string arguments, string verb, int windowStyle, string directory = null)
{
- if (directory == null)
+ if (string.IsNullOrWhiteSpace(directory))
{
ObjectPath.GetFullFilePath(fileName, out var filePath);
directory = Path.GetDirectoryName(filePath);
@@ -48,11 +48,16 @@ public static string GetCommand(string fileName, string arguments, string verb,
}
string psFileName = "'" + fileName.Replace("'", "''") + "'";
- string psDir = string.IsNullOrEmpty(directory) ? "$null" : "'" + directory.Replace("'", "''") + "'";
string psVerb = "'" + verb.Replace("'", "''") + "'";
string psArgs = "'" + arguments.Replace("'", "''") + "'";
- return $"powershell -WindowStyle Hidden -Command \"Start-Process -FilePath {psFileName} -ArgumentList {psArgs} -WorkingDirectory {psDir} -Verb {psVerb} -WindowStyle {winStyleStr}\"";
+ string psDirPart = "";
+ if (!string.IsNullOrWhiteSpace(directory))
+ {
+ psDirPart = $"-WorkingDirectory '{directory.Replace("'", "''")}'";
+ }
+
+ return $"powershell -WindowStyle Hidden -Command \"Start-Process -FilePath {psFileName} -ArgumentList {psArgs} {psDirPart} -Verb {psVerb} -WindowStyle {winStyleStr}\"";
}
else
{
From 6eee2c52679ba27ca51c337ef328b7f82d1ec07d Mon Sep 17 00:00:00 2001
From: CMJNB <53365071+CMJNB@users.noreply.github.com>
Date: Tue, 24 Feb 2026 01:53:06 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=98=B2=E7=81=AB?=
=?UTF-8?q?=E5=A2=99=E8=8F=9C=E5=8D=95=E5=91=BD=E4=BB=A4=E4=B8=BA=20PowerS?=
=?UTF-8?q?hell=20=E5=B9=B6=E4=BC=98=E5=8C=96=E8=8B=B1=E6=96=87=E6=8F=8F?=
=?UTF-8?q?=E8=BF=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
将 EnhanceMenusDic.xml 中防火墙相关菜单项的命令由 cmd+netsh 替换为 PowerShell 脚本,提升规则操作的准确性和兼容性。同时优化英文菜单项描述,使其更符合表达习惯。
---
.../Resources/Texts/EnhanceMenusDic.xml | 34 ++++++++++++-------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml b/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
index e12f581..a54f683 100644
--- a/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
+++ b/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
@@ -1223,30 +1223,34 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
en-US
- cmd.exe
- /R (netsh advfirewall firewall delete rule name="_%1" dir=in program="%1" & netsh advfirewall firewall add rule name="_%1" dir=in program="%1" action=block)
+ powershell.exe
+
+ Get-NetFirewallRule -DisplayName '_%1' | Where-Object { ($_ | Get-NetFirewallApplicationFilter).Program -eq '%1' -and $_.Direction -eq 'Inbound' } | Remove-NetFirewallRule; New-NetFirewallRule -DisplayName '_%1' -Program '%1' -Direction Inbound -Action Block
+
-
+
en-US
- cmd.exe
- /R (netsh advfirewall firewall delete rule name="_%1" dir=out program="%1" & netsh advfirewall firewall add rule name="_%1" dir=out program="%1" action=block)
+ powershell.exe
+
+ Get-NetFirewallRule -DisplayName '_%1' | Where-Object { ($_ | Get-NetFirewallApplicationFilter).Program -eq '%1' -and $_.Direction -eq 'Outbound' } | Remove-NetFirewallRule; New-NetFirewallRule -DisplayName '_%1' -Program '%1' -Direction Outbound -Action Block
+
@@ -1260,8 +1264,10 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
- cmd.exe
- /R (netsh advfirewall firewall delete rule name="_%1" dir=in program="%1" & netsh advfirewall firewall add rule name="_%1" dir=in program="%1" action=allow)
+ powershell.exe
+
+ Get-NetFirewallRule -DisplayName '_%1' | Where-Object { ($_ | Get-NetFirewallApplicationFilter).Program -eq '%1' -and $_.Direction -eq 'Inbound' } | Remove-NetFirewallRule; New-NetFirewallRule -DisplayName '_%1' -Program '%1' -Direction Inbound -Action Allow
+
@@ -1275,8 +1281,10 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
- cmd.exe
- /R (netsh advfirewall firewall delete rule name="_%1" dir=out program="%1" & netsh advfirewall firewall add rule name="_%1" dir=out program="%1" action=allow)
+ powershell.exe
+
+ Get-NetFirewallRule -DisplayName '_%1' | Where-Object { ($_ | Get-NetFirewallApplicationFilter).Program -eq '%1' -and $_.Direction -eq 'Outbound' } | Remove-NetFirewallRule; New-NetFirewallRule -DisplayName '_%1' -Program '%1' -Direction Outbound -Action Allow
+
@@ -1290,8 +1298,10 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
- cmd.exe
- /R (netsh advfirewall firewall delete rule name="_%1" program="%1")
+ powershell.exe
+
+ Get-NetFirewallRule -DisplayName '_%1' | Where-Object { ($_ | Get-NetFirewallApplicationFilter).Program -eq '%1' } | Remove-NetFirewallRule
+
From 00f42dc9f883e1f8b10f08ad177fc6b9c763983c Mon Sep 17 00:00:00 2001
From: CMJNB <53365071+CMJNB@users.noreply.github.com>
Date: Tue, 24 Feb 2026 03:45:13 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=93=88=E5=B8=8C?=
=?UTF-8?q?=E5=80=BC=E8=8F=9C=E5=8D=95=E6=94=AF=E6=8C=81=E5=A4=9A=E7=AE=97?=
=?UTF-8?q?=E6=B3=95=E5=AD=90=E8=8F=9C=E5=8D=95=E4=B8=8E=E9=AB=98=E4=BA=AE?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
将“获取哈希值”菜单由单一命令改为多子菜单结构,支持 MD5、SHA1、SHA256、SHA384、SHA512 及全部算法选项。每项均调用 PowerShell 并以彩色高亮显示结果,提升交互体验和易用性,支持中英文多语言。
---
.../Resources/Texts/EnhanceMenusDic.xml | 121 +++++++++++++++---
1 file changed, 105 insertions(+), 16 deletions(-)
diff --git a/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml b/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
index a54f683..1436c9c 100644
--- a/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
+++ b/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
@@ -47,22 +47,111 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
- -
- 6.3
-
-
-
- en-US
-
-
-
-
-
- powershell.exe
- -noexit write-host '"%1"';$args = 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'mactripledes', 'ripemd160'; foreach($arg in $args){get-filehash '"%1"' -algorithm $arg | select-object algorithm, hash | format-table -wrap}
-
-
-
+ -
+ 6.3
+
+
+
+ en-US
+
+
+
+
+
+
+
+
+
+ en-US
+
+
+
+
+
+ powershell.exe
+ -NoExit -Command "$Host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(512, 50); $h = Get-FileHash '%1' -Algorithm MD5; Write-Host 'File: %1' -ForegroundColor Cyan; Write-Host 'MD5 : ' -NoNewline; Write-Host $h.Hash -ForegroundColor Yellow"
+
+
+
+
+
+
+
+ en-US
+
+
+
+
+
+ powershell.exe
+ -NoExit -Command "$Host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(512, 50); $h = Get-FileHash '%1' -Algorithm SHA1; Write-Host 'File: %1' -ForegroundColor Cyan; Write-Host 'SHA1 : ' -NoNewline; Write-Host $h.Hash -ForegroundColor Yellow"
+
+
+
+
+
+
+
+ en-US
+
+
+
+
+
+ powershell.exe
+ -NoExit -Command "$Host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(512, 50); $h = Get-FileHash '%1' -Algorithm SHA256; Write-Host 'File: %1' -ForegroundColor Cyan; Write-Host 'SHA256 : ' -NoNewline; Write-Host $h.Hash -ForegroundColor Yellow"
+
+
+
+
+
+
+
+ en-US
+
+
+
+
+
+ powershell.exe
+ -NoExit -Command "$Host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(512, 50); $h = Get-FileHash '%1' -Algorithm SHA384; Write-Host 'File: %1' -ForegroundColor Cyan; Write-Host 'SHA384 : ' -NoNewline; Write-Host $h.Hash -ForegroundColor Yellow"
+
+
+
+
+
+
+
+ en-US
+
+
+
+
+
+ powershell.exe
+ -NoExit -Command "$Host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(512, 50); $h = Get-FileHash '%1' -Algorithm SHA512; Write-Host 'File: %1' -ForegroundColor Cyan; Write-Host 'SHA512 : ' -NoNewline; Write-Host $h.Hash -ForegroundColor Yellow"
+
+
+
+
+
+
+
+ en-US
+
+
+
+
+
+ powershell.exe
+ -NoExit -Command "$Host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(512, 50); Write-Host 'File: %1' -ForegroundColor Cyan; Write-Host ('-' * 64); 'MD5','SHA1','SHA256','SHA384','SHA512' | ForEach-Object { $h = Get-FileHash '%1' -Algorithm $_; Write-Host ('{0,-8}: ' -f $h.Algorithm) -NoNewline; Write-Host $h.Hash -ForegroundColor Yellow }; Write-Host ('-' * 64)"
+
+
+
+
+
+
+