this is a whole example ,closeing the process named notepad.exe // using System; using System.Diagnostics;namespace CloseProgram { /// <summary> /// Class1 的摘要说明。 /// </summary> class Class1 { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main(string[] args) { // // TODO: 在此处添加代码以启动应用程序 // Process[] myProcesses; // Returns array containing all instances of Notepad. myProcesses = Process.GetProcessesByName("notepad"); foreach(Process myProcess in myProcesses) { myProcess.Kill(); } } } } // you can create a console program ,copy all the code ,and build it. have a try .
//
using System;
using System.Diagnostics;namespace CloseProgram
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Process[] myProcesses;
// Returns array containing all instances of Notepad.
myProcesses = Process.GetProcessesByName("notepad");
foreach(Process myProcess in myProcesses)
{
myProcess.Kill();
}
}
}
}
//
you can create a console program ,copy all the code ,and build it.
have a try .
http://www.codeproject.com/csharp/wmi.asp
psInfo.FileName = "net.exe";
psInfo.Arguments = "send " + strHost + " "+strMsg;//net send
Process.Start(psInfo);
启动net send命令的例子。