如何使用 C# 阻止 IP 地址通过 Windows 防火墙
我有一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论