频道栏目
首页 > 程序开发 > Web开发 > ASP.Net > 正文
C#版查杀本地/远程进程工具
2004-10-05 09:45:48           
收藏   我要投稿

xkill [原创]

Author: R&S 
E-mail: yrwithsh@vip.sina.com
HomePage: fz5fz.yeah.net
Date: 10/04/2003

using System;
using System.Management;
using System.Threading;

class xkill
{
public static void usage()
{
Console.WriteLine();
Console.WriteLine("xkill v1.0 Beta, By R&S");
Console.WriteLine("E-mail: yrwithsh@vip.sina.com");
Console.WriteLine("H-Page: Http://fz5fz.yeah.net");
Console.WriteLine();
Console.WriteLine("Usage:  xkill [ip] [account] [password] [programme] [time(s)]");
Console.WriteLine("If its the localhost,dont need account and password"); 
Console.WriteLine("Example: xkill 218.194.X.X administrator 123 qq.exe 60");
Console.WriteLine(" xkill 218.194.X.X administrator NULL qq.exe 60");
Console.WriteLine(" xkill 127.0.0.1 qq.exe 60 (for localhost)");

}

public static void Main(string[] args)
{
if((args.Length!=5)&&(args.Length!=3))
{
usage();
Environment.Exit(0);
}
while((args[0]=="127.0.0.1")││(args[0]=="192.168.0.1"))
{
string KillName=args[1];  
ManagementObjectSearcher link = new ManagementObjectSearcher("SELECT * From Win32_Process");
ManagementObjectCollection Collection = link.Get();
foreach (ManagementObject Process in Collection)
{
Console.WriteLine("{0} {1}",Convert.ToString(Process["Name"]).PadRight(15),Process["ExecutablePath"]);
       if (Convert.ToString(Process["Name"])==KillName)
{
string[] Tparas = {"1"}; 
  Process.InvokeMethod("Terminate", Tparas); 
}
 }
Console.WriteLine();
Console.WriteLine("Terminate it yet");
Thread.Sleep(Convert.ToInt32(args[2])*1000);
 }

try{
    do
    {
string KillName=args[3];
ConnectionOptions Conn = new ConnectionOptions(); 
Conn.Username =args[1]; 
if(args[2]=="NULL")
{
Conn.Password ="";
}
else Conn.Password =args[2];
ManagementPath p = new ManagementPath("\\"+args[0]+"\root\cimv2");   
ManagementScope ms = new ManagementScope(p,Conn);
ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_Process");
ManagementObjectSearcher link = new ManagementObjectSearcher(ms,oq);
ManagementObjectCollection Collection = link.Get(); 
     Console.WriteLine("--------------------------------------------------------");
foreach (ManagementObject Process in Collection)
{
Console.WriteLine("{0}{1}",Convert.ToString(Process["Name"]).PadRight(15),Process["ExecutablePath"]);
       if (Convert.ToString(Process["Name"])==KillName)
{
string[] Tparas = {"1"}; 
  Process.InvokeMethod("Terminate", Tparas); 
}

}


Thread.Sleep(Convert.ToInt32(args[4])*1000);  
 }while(true);
}
 catch(Exception exObj)
{
Console.WriteLine();
Console.WriteLine("failed!");
Console.WriteLine(exObj.Message);
}  
}
}

xkill [原创]

Author: R&S 
E-mail: yrwithsh@vip.sina.com
HomePage: fz5fz.yeah.net
Date: 10/04/2003

using System;
using System.Management;
using System.Threading;

class xkill
{
public static void usage()
{
Console.WriteLine();
Console.WriteLine("xkill v1.0 Beta, By R&S");
Console.WriteLine("E-mail: yrwithsh@vip.sina.com");
Console.WriteLine("H-Page: Http://fz5fz.yeah.net");
Console.WriteLine();
Console.WriteLine("Usage:  xkill [ip] [account] [password] [programme] [time(s)]");
Console.WriteLine("If its the localhost,dont need account and password"); 
Console.WriteLine("Example: xkill 218.194.X.X administrator 123 qq.exe 60");
Console.WriteLine(" xkill 218.194.X.X administrator NULL qq.exe 60");
Console.WriteLine(" xkill 127.0.0.1 qq.exe 60 (for localhost)");

}

public static void Main(string[] args)
{
if((args.Length!=5)&&(args.Length!=3))
{
usage();
Environment.Exit(0);
}
while((args[0]=="127.0.0.1")││(args[0]=="192.168.0.1"))
{
string KillName=args[1];  
ManagementObjectSearcher link = new ManagementObjectSearcher("SELECT * From Win32_Process");
ManagementObjectCollection Collection = link.Get();
foreach (ManagementObject Process in Collection)
{
Console.WriteLine("{0} {1}",Convert.ToString(Process["Name"]).PadRight(15),Process["ExecutablePath"]);
       if (Convert.ToString(Process["Name"])==KillName)
{
string[] Tparas = {"1"}; 
  Process.InvokeMethod("Terminate", Tparas); 
}
 }
Console.WriteLine();
Console.WriteLine("Terminate it yet");
Thread.Sleep(Convert.ToInt32(args[2])*1000);
 }

try{
    do
    {
string KillName=args[3];
ConnectionOptions Conn = new ConnectionOptions(); 
Conn.Username =args[1]; 
if(args[2]=="NULL")
{
Conn.Password ="";
}
else Conn.Password =args[2];
ManagementPath p = new ManagementPath("\\"+args[0]+"\root\cimv2");   
ManagementScope ms = new ManagementScope(p,Conn);
ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_Process");
ManagementObjectSearcher link = new ManagementObjectSearcher(ms,oq);
ManagementObjectCollection Collection = link.Get(); 
     Console.WriteLine("--------------------------------------------------------");
foreach (ManagementObject Process in Collection)
{
Console.WriteLine("{0}{1}",Convert.ToString(Process["Name"]).PadRight(15),Process["ExecutablePath"]);
       if (Convert.ToString(Process["Name"])==KillName)
{
string[] Tparas = {"1"}; 
  Process.InvokeMethod("Terminate", Tparas); 
}

}


Thread.Sleep(Convert.ToInt32(args[4])*1000);  
 }while(true);
}
 catch(Exception exObj)
{
Console.WriteLine();
Console.WriteLine("failed!");
Console.WriteLine(exObj.Message);
}  
}
}

点击复制链接 与好友分享!回本站首页
相关TAG标签 进程 工具
上一篇:第一页
下一篇:C#中的cookie编程
相关文章
图文推荐
点击排行

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站