Call taskkill.exe with a keypress detection.

I read all rules, where was: you can post here any topic related to c++. I am sorry in advance, if this is not for help with creating simple c++ programs.

I am beginner to C++. I am trying to make simple program: which would ran in the background, in a console window for what i care, and detected a keypress - (specific hotkey like ctrl+alt+p). And than it would called this exe in system, using following parameters:

 
C:\Windows\System32\taskkill.exe /f /fi “status eq not responding”

Which is for terminating unresponsive programs in Windows 10. I read however this is not most optimal way to do that. I am open to suggestions.

I already tried to google this some time and i always found only way to do this is:
- use extension conio.h
- use deprecated functions
- and run to complicated errors: i have no idea how to fix

Is there some way to do this? Which is conform to Standard C++ library ? I am beginner to programing and i can't figure this myself. Even advice would be great, i am willing to do this myself, i just don't know how!
Last edited on
There is no point using c++ for this. Just put that command in a batch file, either store that batch file on the desktop or put a link to it on the desktop.

Then you can double-click it whenever you like.

C++ programs aren't the best place to put actions that are the natural business of the operating system.
eh, I have written a few super-batch files in c++. I find it easier for complex jobs, where you have to start jumping thru hoops in batch language. But this is too simple for that.

You can put the result in your windows task scheduler and run it every 15 min or something to keep your OS in good order if you have ongoing problems, but it may be better to address why you have these; I only extremely rarely have a program become unresponsive in winx.

you can make it a TSR that fires on some magic key combo too, but you need to use OS libraries to do that, and it gets more complicated quickly. Its not worth it, just put it as the batch file (or program if you insisit) and run on demand or run on a schedule. Basically find a simple task bar program shell example and edit it to respond to your key combo and do the task when that triggers. But such things are awful -- they sit there listening (eating cpu, no matter how small, and some memory too) to do jack all. Most computers that are slow have a ton of these kinds of crapware programs running, doing nothing useful 99.9999% of the time. Run on demand is a clean machine. Run all the time is infested, whether its malware or not, its a type of infestation that needs to die IMHO.

Topic archived. No new replies allowed.