0

I have a full screen application that sometimes hangs up and then suddenly slows my entire PC down my littering the system memory and hogging the CPU at 100% load. I know that you can kill apps using the Task Manager. The only problem is that the application captures every mouse and keyboard input so CTRL+SHIFT+ESC wont work.

If I use the CTRL+ALT+DEL function that brings up the lock screen to open the Task Manager, I still can't use it since I can't use my mouse. Using ALT+TAB to change the focus into Task Manager displays it on top but the mouse is still trapped into the application. Using the keyboard to navigate around in Task Manager doesn't work either, since the application immediately captures any keyboard input and changes the focus back to itself and Task Manager is hidden again.

Checking "Keep in front" of Task Manager makes it at least stay on top, but I still can't use it with my keyboard or mouse. Trying ALT+TAB and then selecting any other window will only change the focus for a short time before changing back to the application. Pressing the Windows key will pop up the taskbar and the start menu but as soon as I try to click on the start menu or taskbar, right click or left click, just brings the application back to front. The application doesn't respond to ALT+F4, no matter how many times I do that shortcut.

The only solution I got so far is to use the CTRL+ALT+DEL lock screen and then to log off my account or to just shut down my entire computer.

Is there a way to create... like a kill switch that will immediately kill any task no questions asked and will work even if the application hangs up and my computer slows down due to CPU and RAM overload?

0

2 Answers 2

0

Instead of trying to kill the app after it's hogging all resources, try setting it to run at a lower priority. You can do this with Task Manager on the Details tab, as shown below:

Set Process Priority

However, you can also write a short script to start the app, and then use setpriority to decrease its CPU usage:

start " " "<full_path_to_application"
wmic process where name="<process_name>" CALL setpriority 64

That said, your situation points to a very badly written application! Since NT, Windows has used preemptive multitasking. While the older cooperative multitasking presumed each process was 'polite', and would eventually yield time to the next process in the queue, preemptive multitasking allots only so much time before suspending a process and letting the next have time on the CPU, so the keyboard and mouse should never be unavailable (though they might be very slow to respond). Are you running an old app in a Windows 3.1 emulator? Unless it's a proprietary app you must use in your work environment, look for a replacement.

1
  • I have this game that if it crashes it forces me to restart my PC lol. Is it possible to run that app (and all apps) in a way that if it crashes, it gets killed (or at least lets me move my mouse and alt tab)? I use windows 11
    – Noel
    Oct 5, 2022 at 16:58
0

You can give try for this batch file inspired from this code Embed PowerShell code in a batch file in order to run it in loop and check every minute for non responding tasks, so when he found, he will kill them !


@echo off
@REM https://martin77s.wordpress.com/2018/01/25/embed-powershell-code-in-a-batch-file/
@Title Get And Kill No Responding Processes
@setlocal EnableDelayedExpansion
@set LF=^


@SET command=#
@FOR /F "tokens=*" %%i in ('findstr -bv @ "%~f0"') DO SET command=!command!!LF!%%i
@powershell -noprofile -noexit -command !command! & goto:eof


# *** POWERSHELL CODE STARTS HERE *** #
While ($True) {
    $DateTime = $Null
    $DateTime = get-date
    Try { 
        $Processes = Get-Process -EA Stop 
        $nProcesses = @($Processes | Where { $_.Responding -eq $false })
    } catch {
        Write-Error "Failed to query processes. $_"
    }
    if($nProcesses) {
        foreach($nProcess in $nProcesses) {
            $nProcess | select ID,Name, MainWindowTitle,Path
            Stop-process -Force $nProcess
        }
    } else {
            #Clear-Host
            Write-host "$DateTime - All processes are OK and are responding." -ForegroundColor Yellow 
        }
    Start-Sleep -s 60
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .