Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

C# kill or terminate running process

$
0
0

I'm using external exe file in my C# code. please check below code. this code i just find some web site.

string str =@"C:\joseph_Test\external_vendor.exe";Process myprocess =newProcess();
        myprocess.StartInfo.FileName= str;
        myprocess.Start();

i cheked this code is working. and no problem. but next test i need to use another different type of external exe file. and i aware that previous 'myprocess' is still alive. even i restart program, myprocess is still alive. So i search internet that how to kill or terminate exisiting process. weird thing is that myprocess never terminated.

first i try below but process still alive.

        myprocess.WaitForExit();
        myprocess.Close();

use below link also not killed.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/50ecbcf2-d2d3-4f21-9775-5b8be1bd4346/how-to-terminate-a-process-in-c?forum=csharpgeneral

also not terminated with below way.

http://stackoverflow.com/questions/3345363/kill-some-processes-by-exe-file-name

i suspect this exe file made by vendor so this happen caused. But the theory is C# create process instance so i believe C# could terminate or kill this process.

please advice for me.

thanks

Joseph Choi


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>