首页 / C# / C#版查杀本地/远程进程工具
C#版查杀本地/远程进程工具
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了C#版查杀本地/远程进程工具,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5106字,纯文字阅读大概需要8分钟。
内容图文
![C#版查杀本地/远程进程工具](/upload/InfoBanner/zyjiaocheng/1069/776a343c05814864963590ab7ced2fac.jpg)
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);
}
}
}
原文:http://www.cnblogs.com/gc2013/p/4151088.html
内容总结
以上是互联网集市为您收集整理的C#版查杀本地/远程进程工具全部内容,希望文章能够帮你解决C#版查杀本地/远程进程工具所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。