开发者

C# stop a process

I would to be able to stop a typeperf process i started in c# for remote machines. What i got so far is:

ProcessStartInfo proc = new ProcessStartInfo();

public void startLogs()
{
    for (int i = 0; i < remote_machines_num; i++)
    {
        string line = " -s " + mach开发者_运维技巧ines[i] 
            + " -si 5 \"\\Processor(_Total)\\% Processor Time\" -o C:\\logs\\" 
            + machines[i] + ".csv";

        proc.FileName = @"C:\WINDOWS\SYSTEM32\typeperf.exe";
        proc.Arguments = line;
        Process.Start(proc);
    }
}

this really starts all monitors - but i would like to write a function that will stop monitoring and close all windows - how can i do that? thanks!


Get a reference to the started process and Kill() it.

var theRunningProc = Process.Start(proc);
theRunningProc.Kill();


Are you looking for this

http://alperguc.blogspot.com/2008/11/c-process-processgetprocessesbyname.html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜