0

I'm trying to terminate GTA 5 when it doesn't respond, but when I run the batch file, it says :

"SUCCESS: Sent termination signal to the process with PID 3220."

But it doesn't stop it.

taskkill /fi "imagename eq GTA5.exe" /fi "status eq Not Responding"

I also tried to use tasklist and extract from it if the task isn't responding, but I didn't find out how.

taylor.2317
  • 582
  • 1
  • 9
  • 23
  • 3
    Read the message: it says, it successfully sent a termination signal to the process, not that it successfully terminated the process. Some processes don't act on this signal (either because it's not programmed to do so or because the process isn't able anymore to do so). You can try the `/f` (force) parameter, but not even that is guaranteed to work. – Stephan Dec 19 '21 at 21:06
  • We would also need much more information. Generally people who play games like this, don't run them directly, they are run from Steam and use Launchers. When these things are introduced there are many dependencies which form part of the running of your game, which could effectively lock/hold that running executable. I would also ask that you first provide us with the output from the following command lines: `%SystemRoot%\System32\tasklist.exe /Fi "ImageName Eq GTA5.exe" /Fo "CSV" /V`, and `%SystemRoot%\System32\wbem\WMIC.exe Process Where "Name='GTA5.exe'" Get /Format:'CSV'`. – Compo Dec 19 '21 at 23:53

1 Answers1

0

You can give try for this Embed PowerShell code in a batch file


@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 - No non-responding processes found" -ForegroundColor Yellow 
        }
    Start-Sleep -s 60
}
Hackoo
  • 18,337
  • 3
  • 40
  • 70