如何将我的右键单击上下文菜单项添加到Windows 11中的现代上下文菜单中



我已经编写了这个PowerShell脚本来自动阻止Windows防火墙中文件夹内的可执行文件

$currentdir = get-Location
cd $currentdir

function FirewallBlock { 
param ($exes)


$exes | ForEach-Object { New-NetFirewallRule -DisplayName "$_.name inbound" -Direction Inbound -Action Block -Profile Any -Program $_.DirectoryName }
$exes | ForEach-Object { New-NetFirewallRule -DisplayName "$_.name outbound" -Direction Outbound -Action Block -Profile Any -Program $_.DirectoryName }

}

$programs = dir -Recurse *.exe
FirewallBlock ($programs)

通过在此处创建2个注册表项将其添加到旧式上下文菜单中:

ComputerHKEY_CLASSES_ROOTDirectoryBackgroundshellFirewall

这里是

ComputerHKEY_CLASSES_ROOTDirectoryBackgroundshellFirewallcommand

防火墙密钥具有默认名称和值";防火墙阻止程序";

命令键具有的默认名称和字符串值

powershell -command "Start-Process pwsh.exe -ArgumentList '-file C:UsersUserNameOneDriveDesktopFirewall.ps1' -Verb runAs"

如何将此上下文菜单选项添加到Windows 11中新的现代上下文菜单样式中?

到目前为止,我发现了这一点,但不知道是否真的必须用这个简单的PowerShell脚本创建一个程序才能将其添加到那里。

https://blogs.windows.com/windowsdeveloper/2021/07/19/extending-the-context-menu-and-share-dialog-in-windows-11/

我一直在寻找同样的东西很长一段时间了,终于找到了最好的方法!

实际上,你可以在不为其制作整个应用程序的情况下做到这一点。你可以使用Microsoft Store中的自定义上下文菜单应用程序,它可以让你在新的Windows 11上下文菜单中添加任何你想要的内容。

半年来,我一直在寻找这个,现在我找到了一个有效的解决方案,感觉很好。

最新更新