通过ASPNET可以对一些无用的进程进行远程杀死下面的代码先列出正在活动的所有进程然后进行杀死需要注意的是这个文件要放在具有Administrator访问权限的虚拟目录下
以下是C#代码
<%@ Page Language=c# %>
<HTML>
<HEAD>
<% @ Import namespace= SystemDiagnostics %>
<script language=C# runat=Server debug=true>
void Page_Load(Object Sender EventArgs e){
btnKillAttributesAdd(onclick javascript: return confirm(你真的要杀死这个进程吗?););
}
private void KillProcess(string processName){
SystemDiagnosticsProcess myproc= new SystemDiagnosticsProcess();
//得到所有打开的进程
try{
foreach (Process thisproc in ProcessGetProcessesByName(processName)) {
if(!thisprocCloseMainWindow()){
thisprocKill();
}
}
}
catch(Exception Exc)
{
msgText+= 杀死 +procnameSelectedItemText + 失败!;
}
}
public void btnKill_Click(object sender SystemEventArgs e)
{
KillProcess(procnameSelectedItemText);
msgText= procnameSelectedItemText + 已经被杀死;
}
public void btnShow_Click(object sender SystemEventArgs e){
ArrayList procList =new ArrayList();
string tempName=;
int begpos;
int endpos;
foreach (Process thisProc in SystemDiagnosticsProcessGetProcesses()) {
tempName=thisProcToString();
begpos = tempNameIndexOf(()+;
endpos= tempNameIndexOf());
tempName=tempNameSubstring(begposendposbegpos);
procListAdd(tempName);
}
procnameDataSource=procList;
procnameDataBind();
}
</script>
</HEAD>
<body>
<Basefont Face=Tahoma />
<center><h>ASPNET 进程杀死器!</h><BR>
<Table cellspacing= cellpadding= border= BGCOLOR=#fFCC>
<form id=frmProc runat=Server method=post>
<TR><TD><ASP:DropDownList id=procname runat=server /></TD><TD>
进程名字</TD></TR>
<TR><TD>
<asp:button id=btnKill Text=杀死进程 runat=server CausesValidation=False onclick=btnKill_Click />
</TD>
<TD><asp:button id=btnShow Text=列出所有进程 runat=server CausesValidation=False onclick=btnShow_Click />
</TD></TR>
</TABLE>
<center><asp:Label id=msg runat=server/></center>
</form>
</center>
</body>
</HTML>