Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

c# - Kill a running process

I would like kill this process but this code isn't work, because the process still work.

My code:

ProcessStartInfo processInfoOrient = new ProcessStartInfo()
{
    FileName = @"B:dborientdb-3.0.29inserver.bat",
    UseShellExecute = true,
    CreateNoWindow = false,
    WorkingDirectory = @"B:dborientdb-3.0.29in"
};

Process processOrient = new Process();
processOrient.StartInfo = processInfoOrient;
processOrient.Start(); //works fine
//work
//work
processOrient.Kill(); //this not working, window (cmd) isn't close and process works. I don't get any of errors.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We had to kill the Java process after OrientDB process and works fine :) Sample code:

prc.Kill();
Process[] prcJava;
prcJava = Process.GetProcessesByName("java");
prcJava[0].Kill();
               

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...