如何阻止互联网访问过程?对于所有Windows [英] How to block a process of Internet access? For All Windows
本文介绍了如何阻止互联网访问过程?对于所有Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
如何削减不断增长的互联网访问流程?
我想阻止互联网仅用于进程,不阻止所有互联网缓冲区。
什么?
解决方案
这里有一个答案可以让你走上正确的道路:
任何使用c#在Windows中关闭互联网的方法? [< a href =http://stackoverflow.com/questions/1242566/any-way-to-turn-the-internet-off-in-windows-using-ctarget =_ blank> ^ ]
如何使以下方法仅适用于一个进程?
使用 System.Diagnostics;
使用 System.IO;
使用 System.Reflection;
private void button1_Click(对象发件人,EventArgs e)
{
// 添加对系统的参考.VIAICEPROCESS通过项目 - >添加参考,.NET选项卡
System.ServiceProcess.ServiceController scPAServ = new System.ServiceProcess.ServiceController(< span class =code-string> PolicyAgent); // IPSec
if (scPAServ.Status!= System.ServiceProcess.ServiceControllerStatus.Running)
{
scPAServ.Start(); // 如果未运行则启动
}
string [] strCommands = {
@ - w REG -p防火墙-r全部阻止 - f *:*:* + *:*:* -n BLOCK -x,
@ - w REG -p防火墙-r允许LAN - f 0:*:* + 192.168.10。*:*:* -n PASS -x,
@ - w REG -p防火墙 -rDNS - f 0:*:UDP + 223.211.190.23:53:UDP 0:*:UDP + 223.211.190.24:53:UDP 0:*:TCP + 223.211.190.23:53:TCP
0:*:TCP + 223.211.190.24:53:TCP -n PASS -x,
@ - w REG -p防火墙-rPOP3 - f 0:*:TCP + *:110:TCP -n PASS -x,
@ - w REG -p防火墙-rPOP3S - f 0:*: TCP + *:995:TCP -n PASS -x,
@ - w REG -p防火墙-rFTP控制 - f 0:* :TCP + *:21:TCP -n PASS -x,
@ - w REG -p防火墙-rFTP数据 - f 0:*:TCP + *:20:TCP -n PASS -x,
@ - w REG -pFirewall - rIMAP - f 0:*:TCP + *:143:TCP -n通过-x,
@ - w REG -p防火墙 - rHTTP - f 0:*:TCP + *:80:TCP -n PASS -x,
@ < span class =code-string> - w REG -pFirewall - rHTTPS - f 0:*:TCP + *:443:TCP -n BLOCK -x,
@ - w REG -pFirewall - rPROXY - f 0: *:TCP + *:8080:TCP 0:*:TCP + *:3128:TCP 0:*:TCP + *:8081:*:TCP 0:*:TCP + *:8000:TCP -n BLOCK -x };
for ( int i = 0 ; i < strCommands.Length; i ++) // 遍历每个命令字符串
{
ProcessStartInfo psiStart = new ProcessStartInfo(); // 处理开始
psiStart.CreateNoWindow = 真跨度>; // Invisible
psiStart.FileName = Directory.GetParent(Assembly.GetExecutingAssembly ()。Location)+ \\ipseccmd.exe; // IPSEC
psiStart.Arguments = strCommands [i]; // Break Command Strings Apart
psiStart.WindowStyle = ProcessWindowStyle.Hidden; // 不可见
流程p = System.Diagnostics.Process.Start( psiStart); // 启动进程阻止Internet连接
}
}
private void button2_Click( object sender,EventArgs e)
{
System.ServiceProcess.ServiceController scPAServ = new System.ServiceProcess.ServiceController( PolicyAgent); // IPSec
if (scPAServ.Status!= System.ServiceProcess.ServiceControllerStatus.Running) // 如果未运行
{
scPAServ.Start();
}
string strCommands = @ -w REG -p防火墙-r全部阻止-f *:*:* + *:*:* -n BLOCK -y; // 要发送的命令
ProcessStartInfo psiStart = new ProcessStartInfo(); // 处理开始
psiStart.CreateNoWindow = 真跨度>; // Invisible
psiStart.FileName = Directory.GetParent(Assembly.GetExecutingAssembly ()。Location)+ \\ipseccmd.exe; // IPSEC
psiStart.Arguments = strCommands; // 将命令字符串作为参数
psiStart.WindowStyle = ProcessWindowStyle.Hidden ; // 不可见
流程p = System.Diagnostics.Process.Start( psiStart); // 启动流程停止互联网连接
}
}
hi
How to cut a growing process of Internet access?
I want to block Internet just for a process, Not block all Internet buffer.
what?
解决方案
Here there's an answer which can put you on the right road:
Any way to turn the "internet off" in windows using c#?[^]
How can I make the following method applies only to one process?
using System.Diagnostics; using System.IO; using System.Reflection; private void button1_Click(object sender, EventArgs e) { //ADDED A REFERENCE TO SYSTEM.SERVICEPROCESS VIA PROJECT->ADD REFERENCE, .NET tab System.ServiceProcess.ServiceController scPAServ = new System.ServiceProcess.ServiceController("PolicyAgent"); //IPSec if (scPAServ.Status != System.ServiceProcess.ServiceControllerStatus.Running) { scPAServ.Start(); //Start If Not Running } string[] strCommands = { @"-w REG -p ""Firewall"" -r ""Block All"" -f *:*:*+*:*:* -n BLOCK -x" , @"-w REG -p ""Firewall"" -r ""Allow LAN"" -f 0:*:*+192.168.10.*:*:* -n PASS -x" , @"-w REG -p ""Firewall"" -r ""DNS"" -f 0:*:UDP+223.211.190.23:53:UDP 0:*:UDP+223.211.190.24:53:UDP 0:*:TCP+223.211.190.23:53:TCP 0:*:TCP+223.211.190.24:53:TCP -n PASS -x" , @"-w REG -p ""Firewall"" -r ""POP3"" -f 0:*:TCP+*:110:TCP -n PASS -x" , @"-w REG -p ""Firewall"" -r ""POP3S"" -f 0:*:TCP+*:995:TCP -n PASS -x" , @"-w REG -p ""Firewall"" -r ""FTP Control"" -f 0:*:TCP+*:21:TCP -n PASS -x" , @"-w REG -p ""Firewall"" -r ""FTP Data"" -f 0:*:TCP+*:20:TCP -n PASS -x" , @"-w REG -p ""Firewall"" -r ""IMAP"" -f 0:*:TCP+*:143:TCP -n PASS -x" , @"-w REG -p ""Firewall"" -r ""HTTP"" -f 0:*:TCP+*:80:TCP -n PASS -x" , @"-w REG -p ""Firewall"" -r ""HTTPS"" -f 0:*:TCP+*:443:TCP -n BLOCK -x" , @"-w REG -p ""Firewall"" -r ""PROXY"" -f 0:*:TCP+*:8080:TCP 0:*:TCP+*:3128:TCP 0:*:TCP+*:8081:*:TCP 0:*:TCP+*:8000:TCP -n BLOCK -x"}; for (int i = 0; i < strCommands.Length; i++) //Loop through each Command String { ProcessStartInfo psiStart = new ProcessStartInfo(); //Process To Start psiStart.CreateNoWindow = true; //Invisible psiStart.FileName = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "\\ipseccmd.exe"; //IPSEC psiStart.Arguments = strCommands[i]; //Break Command Strings Apart psiStart.WindowStyle = ProcessWindowStyle.Hidden; //Invisible Process p = System.Diagnostics.Process.Start(psiStart); //Start Process To Block Internet Connection } } private void button2_Click(object sender, EventArgs e) { System.ServiceProcess.ServiceController scPAServ = new System.ServiceProcess.ServiceController("PolicyAgent"); //IPSec if (scPAServ.Status != System.ServiceProcess.ServiceControllerStatus.Running) //If Not Running { scPAServ.Start(); } string strCommands = @"-w REG -p ""Firewall"" -r ""Block All"" -f *:*:*+*:*:* -n BLOCK -y"; //Commands To Send ProcessStartInfo psiStart = new ProcessStartInfo(); //Process To Start psiStart.CreateNoWindow = true; //Invisible psiStart.FileName = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "\\ipseccmd.exe"; //IPSEC psiStart.Arguments = strCommands; //Give Command String As Argument psiStart.WindowStyle = ProcessWindowStyle.Hidden; //Invisible Process p = System.Diagnostics.Process.Start(psiStart); //Start Process To Stop Internet Connection } }
这篇关于如何阻止互联网访问过程?对于所有Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文