C# 杀掉指定exe进程

public static void KillApp(string appName)

{

try

{

if (string.IsNullOrWhiteSpace(appName) || !appName.EndsWith(".exe")) return; //

ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.FileName = "taskkill.exe";

startInfo.Arguments = string.Format(" /f /t /im {0}", appName);

startInfo.WindowStyle = ProcessWindowStyle.Hidden;

startInfo.Verb = @"runas";

Log.Debug(string.Format("KillApp run kill {0} start", appName));

Process process = Process.Start(startInfo);

process.WaitForExit();

Log.Debug(string.Format("KillApp run kill {0} end", appName));

}

catch (System.Exception ex)

{

Log.Error(string.Format("KillApp run kill {0} failed ", appName), ex);

}

}

相关推荐
淡海水24 分钟前
07-04-源码-.NET Core GC清扫与压缩
unity·架构·c#·.netcore·gc·1024程序员节
zwm2698888158 小时前
hd 3#负一西送风,能远程启不能远程停
c#
Ai-_Man9 小时前
Meta Muse还是不可以导出左侧所有对话,只能点进去单条内容导出,方法不对吗?
开发语言·人工智能·ai·小程序·c#·1024程序员节
2401_8858850417 小时前
国际语音C#接口怎么写?.NET环境下实现国际语音验证码批量下发
开发语言·c#·.net
淡海水1 天前
07-03-源码-.NET Core GC标记与扫描
unity·c#·.netcore·gc
波力海苔夹心脆6751 天前
C# string 字符串方法大全:判空、查找、截取、分割、替换一篇讲透
经验分享·c#·.net·字符串·string·入门教程
阿松爱学习2 天前
【Unity开发】Unity长截图功能实现
unity·c#·游戏引擎
_oP_i2 天前
Windows 11 家庭中文版 25H2
c#
unicrom_深圳市由你创科技2 天前
电池化成曲线MES追溯:关键点提取与验证
c#
老王IT2 天前
C#语言基础语法介绍
开发语言·c#