Windows – send CTRL-BREAK and/or CTRL-C to a running process in Windows

command-line-interfacewindows

I have a Windows Console application that will be running for an extended period of time. This has been developed in house and tests have shown that over time memory usage grows and other bad things ensue. The Developers can't correct all the issues in time for release, so I'm looking for a way to end and restart the process on a periodic basis. I already have a Windows Scheduled task that runs a batch file, checks if the process is running and if not, starts it.

Now I need something that stops it gracefully. The application has commandeered the CTRL-BREAK event as a request for a controlled shutdown. I'd like to send it that CTRL-BREAK and if it still doesn't end after some period of time, then I could use taskkill to end it forcefully. taskkill seems to feed it a CTRL-CLOSE event. Is there some way to feed CTRL-BREAK to a process from the command line?

Best Answer

You can send a control-break with this little utility.

http://www.latenighthacking.com/projects/2003/sendsignal/

note Make sure to use start if you are running it from a batch file.