如何按进程描述终止进程

时间:2015-04-04 22:14:26

标签: c# vb.net process kill

1.my code kill process

foreach (Process s1 in Process.GetProcessesByName("test"))
                {
                    s1.Kill();
                }

2.我的代码检查说明

FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(@"C:\test\test.exe");
                label1.Text = ""+ ("File: " + myFileVersionInfo.FileDescription);

1 个答案:

答案 0 :(得分:0)

VB.NET

Dim FileDes As String = String.Empty '//FileDescription
        For Each x As Process In Process.GetProcesses
            If FileDes = x.MainModule.FileVersionInfo.FileDescription Then
                x.Kill()
            End If
        Next

C#

string FileDes = string.Empty; //FileDescription
foreach (Process x in Process.GetProcesses) {
    if (FileDes == x.MainModule.FileVersionInfo.FileDescription) {
        x.Kill();
    }
}