如何使用 C# 阻止 IP 地址通过 Windows 防火墙

发布于 2025-01-12 22:16:57 字数 483 浏览 3 评论 0原文

我有一个 C# 应用程序来阻止网站。这是我的代码:

blsite.StartInfo.FileName = ("powershell.exe");
blsite.StartInfo.UseShellExecute = false;
blsite.StartInfo.Arguments = "New-NetFirewallRule -DisplayName 'Block-example_com' -Direction Outbound –LocalPort Any -Protocol Any -Action Block -RemoteAddress 93.184.216.34";
blsite.Start();
blsite.WaitForExit();

我已经运行了它,但它不起作用,即使在 Windows Defender 防火墙中显示了我的规则。

我尝试删除该规则,并直接通过powershell运行上述命令得到页面被阻止的结果。

抱歉我的英语不好

I have a C# application to block an website. And this is my code:

blsite.StartInfo.FileName = ("powershell.exe");
blsite.StartInfo.UseShellExecute = false;
blsite.StartInfo.Arguments = "New-NetFirewallRule -DisplayName 'Block-example_com' -Direction Outbound –LocalPort Any -Protocol Any -Action Block -RemoteAddress 93.184.216.34";
blsite.Start();
blsite.WaitForExit();

I have run it, but it didn't work, even though in Windows Defender Firewall showed my rule.

I tried removing that rule, and running the above command directly through powershell got the result that the page was blocked.

Sorry for my poor English

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文