惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
V
V2EX
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
F
Full Disclosure
Y
Y Combinator Blog
V
V2EX - 技术
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
SecWiki News
SecWiki News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
量子位
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
K
Kaspersky official blog
B
Blog
A
Arctic Wolf
Hacker News: Ask HN
Hacker News: Ask HN
L
LangChain Blog
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
Lohrmann on Cybersecurity
D
Docker
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - 东哥技术专栏 - Coldwine's Blog

SQL Server Transactional Replication 中的 CommitBatchSize 和 CommitBatchThreshold 属性 转: SQL Server Analysis Service中Cube的结构 Cannot connect to an Analysis Services named instance after installing SQL Server Express 今天遇到一个问题才知道如果安装了命名实例 SSIS Service 需要手动更改配置文件 Data Mining Tutorial数据挖掘教程 (PART-1) 一些关于“数据挖掘介”技术的有用文档 The Fundamentals of the SQL Server 2005 XML Datatype SSL协议与数字证书原理 (ZT) PKI 技术白皮书 (ZT) Windows 2000 公钥基础结构详解 (ZT) SQL Server 2000 之前的版本号对照表 关于 c# 的 Partial Class 关于ASP.NET CS1595 问题 开发人员的十种必备工具 ASP.NET中的状态管理 关于SqlDataReader一些用法 使用附属程序集的一些经验 使用C#建立WINDOWS服务 . Net环境下消息队列(MSMQ)对象的应用
ASP.NET中编程杀死进程
东哥技术专栏 - Coldwine's Blog · 2005-08-01 · via 博客园 - 东哥技术专栏 - Coldwine's Blog

通过ASP.NET可以对一些无用的进程进行远程杀死,下面的代码先列出正在活动的所有进程,然后进行杀死。需要注意的是:这个文件要放在具有Administrator访问权限的虚拟目录下。



<%@ 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(")");
tempName
=tempName.Substring(begpos,endpos-begpos);
procList.Add(tempName);
}

procname.DataSource
=procList;
procname.DataBind();
}

</script>
</HEAD>
<body>
<Basefont Face="Tahoma" />
<center><h2>ASP.NET 进程杀死器!</h2><BR>
<Table cellspacing=2 cellpadding=2 border=0 BGCOLOR="#fFCC66">
<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>