views:

57

answers:

2

I have some .exe name i want to terminate if its running, how?

Edit: I modified mike's example to this, and its perfect:

WinExec("taskkill /IM notepad.exe /F", SW_HIDE);
+2  A: 

Without trying to be rude, but just use Google? Here's what I found in a quick search:

Kyle Rozendo
yeah which one of those are the best?
Newbie
Look at the code project ones. They're rated by programmers, so the better ranking, the better (in general).
Kyle Rozendo
Google can turn up all sorts of stuff, frequently of dubious relaibility. It requires a certain amount of expertise to assess whether the top hits in Google are correct or safe (especially as they can contradict each other). This is a general observation, and I am not maligning any of the links you have posted.
APC
A: 

If you know the name of a process to kill, for example notepad.exe, use the following command from a command prompt to end it

taskkill /IM notepad.exe

This will cause the program to terminate gracefully, asking for confirmation if there are unsaved changes. To forcefully kill the same process, add the /F option to the command line. Be careful with the /F option as it will terminate all matching processes without confirmation.

Mike
perfect! thats all i needed.
Newbie