http://topic.csdn.net/t/20040611/10/3082854.html
<%@
Page
Language="c#" %>
<HTML>
<HEAD>
<% @
Import namespace=
"System.Diagnostics"
%>
<script
language="C#" runat="Server"
debug="true">
void Page_Load(Object
Sender, EventArgs
e){
btnKill.Attributes.Add("onclick",
"javascript: return
confirm('你真的要杀死这个进程吗?');");
}
private void
KillProcess(string
processName){
System.Diagnostics.Process myproc=
new
System.Diagnostics.Process();
//得到所有打开的进程
try{
foreach
(Process thisproc in
Process.GetProcessesByName(processName))
{
if(!thisproc.CloseMainWindow()){
thisproc.Kill();
}
}
}
catch(Exception
Exc)
{
msg.Text+=
"杀死"
+procname.SelectedItem.Text +
"失败!";
}
}
public void
btnKill_Click(object sender,
System.EventArgs e)
{
KillProcess(procname.SelectedItem.Text);
msg.Text=
procname.SelectedItem.Text +"
已经被杀死。";
}
public void
btnShow_Click(object sender,
System.EventArgs e){
ArrayList procList
=new ArrayList();
string tempName="";
int begpos;
int endpos;
foreach
(Process thisProc
in
System.Diagnostics.Process.GetProcesses()) {
tempName=thisProc.ToString();
begpos =
tempName.IndexOf("(")+1;
endpos=
tempName.IndexOf(")");