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
{
diff --git a/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml b/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
index e12f581..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)"
+
+
+
+
+
+
+
@@ -1223,30 +1312,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 +1353,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 +1370,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 +1387,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
+