If you want to detect and react to a specific something in Windows, the most efficient way is with Event viewer. Build an event that will catch this hangup and end the task.
Open Event Viewer (eventvwr.msc) and create a custom view.
For this event, it could range many levels since level lag varies. Let's check critical, error, and information. In this case, we're tracking the sources of the events themselves, not their logs. Hit the "By source" radio button. In the dropdown, select Application Error & Application Hang.
Just to be on the safe side (if the keywords/sources aren't effective for whatever reason), we'll enter three very common event IDs for crashing. Enter 1,1000,1002 in the ID text field.
(If you'd like to look up more event IDs, you can find them here).
Our keywords are "Response Time" since we're concerned with our application responding. You can leave the User and Computer text fields as they are.
Custom View Configuration Capture
Hit OK. We now have an event that's aware of when a program crashes on our computer. Now all we have to do is make it do something when that happens. Still in event viewer, "Attach Task To This Custom View..." In the Wizard, go to Action. We want to run a command when this event occurs. Our command is taskkill
, and the arguments going in the "Add arguments" field are /F /FI "STATUS eq NOT RESPONDING" /FI "WINDOWTITLE ne untitle*"
You can now finish out of the Wizard.
[Regrettably, I don't have enough reputation to link all the things I was going to. It's my first day; sorry.]
Now when triggered, this view will shut down any processes that aren't responding. If you'd like to add more arguments for taskkill
, they can be viewed in cmd with taskkill /?
Hitting ALT+F4 would end the video game itself. This would immediately solve your CPU usage problem, although the process you ran, would indeed be able to use more of your CPU. In other words being, careful about what you run, is the best solution to a problem like this. If the process using the CPU had a window, ALT+F4, will close the windows explorer window of any process (in other words terminate the process) – Ramhound – 2015-12-02T23:16:49.453