Would love to know how to integrate GPU Threshold once reached.

For example below 10% Usage for the Program/App to exit and if possible in a batch file, I've tried with a mix of CPU+memory threshold but that don't always work properly in all Apps, so I thought GPU threshold would solve this since it is pretty definite at times unlike CPU+memory thresholds which can vary greatly sometimes.

Here's a batch example for the threshold that needs a GPU threshold included

@echo OFF
@start "" "DOOMx64vk.exe" +devMode_Enable 1 +com_restarted 1 +com_gameMode 1 +com_skipIntroVideo 1 +exec DOOMConfig.cfg 1 +image_usecompression 0 +com_skipKeyPressOnLoadScreens 1
:: set process_name:
 set process_name=DOOMx64vk.exe
cd /D "C:\Program Files\NVIDIA Corporation\NVSMI\"
for /f skip^=8^ tokens^=1-3^ delims^=^| %%a in ('"nvidia-smi.exe"') do (
    for /f "tokens=1-6 delims= " %%g in ("%%a") do set u=%%g & set v=%%h) & set w=%%j) & (
    for /f "tokens=1-3 delims= " %%g in ("%%b") do set x=%%g & set y=%%i) & (
    for /f "tokens=1-2 delims= " %%g in ("%%c") do set z=%%g) & goto :breakForLoop
set /a u+=0 & set /a v+=0 & set /a w+=0 & set /a x+=0 & set /a z+=0
set /a u=u & set /a v=v & set /a w=w & set /a x=x & set /a z=z
echo %u%, %v%, %w%, %x%, %y%, %z%
timeout /t 5
goto GPU
if %z% Lss 20 TaskKill /F /im %process_name% & goto RUNNING
timeout /t 3
tasklist|findstr %process_name% > nul &&
    taskkill /F /T /IM "cheatengine-x86_64.exe" & taskkill /F /T /IM "Werfault.exe" & exit /b
timeout /t 1
  • What is your final goal? Why do you need to kill an app once it reaches a certain gpu/cpu/memory threshold? By describing that it might be that there are other ways to achieve that goal. – Saaru Lindestøkke Aug 16 '20 at 18:16
  • well my final goal is as ive mentioned i need function like above for cpu+memory , but additionally for the gpu , so as soon as its below threshold itll exit said app , would be appreciated for sure , i really need that gpu function – Etherpixel56 Aug 17 '20 at 15:39
@echo off && Setlocal EnableDelayedExpansion

set "_process_name=Folding.exe" && cmd /v /c "set "_pn=!_process_name:~0,-4!""
set /a "_cpuThreshold=10, _memThreshold=450000" && start "" "!_process_name!"

timeout 2 & for /f tokens^=2delims^=^= %%f in (
'wmic cpu get NumberOfCores /value')do ^< nul set "_NumberOfCores=%%~f"

set /a "_process_snapshot=0, _memUsg=0"

for /f skip^=2tokens^=3delims^=^" %%p in ('
typeperf "\Process(!_pn!)\%% Processor Time" -sc 1
')do for /f tokens^=1delims^=. %%a in ('echo\%%~p
')do set /a "_process_snapshot=%%~a/!_NumberOfCores!"

if !_process_snapshot! LSS !_cpuThreshold! (
     set /a "_low+=1+0") else set /a "_low-=_low"

for /f tokens^=5 %%p in ('tasklist ^|findstr.exe "!_process_name!"
')do for /f tokens^=1*delims^=^, %%a in ("%%~p")do set "_memUsg=%%~a%%~b"

if !_memUsg! lss !_memThreshold! (set /a "_low+=1+0") else set /a "_low-=_low"
echo\process_snapshot: !_process_snapshot!, memUsage: !_memUsg!, LowCpuAndMem: !_low!

if !_low! GEQ 12 taskkill /F /T /IM !_process_name! && goto=:RUNNING // where is ???  
timeout 3 & tasklist|findstr /i "!_process_name!" >nul && GOTO=:CheckCpuAndMem

exit /b 

GOTO=:RUNNING // where is ???  

You have a conflict in your code, you define a value in thousands for memThreshold, but use a condition in hundreds ( set /a memUsg=%%a%%b%%c/1000 ) within the if memUsg000 lss memThreshold000:

set memThreshold=450000
) do set /a memUsg=%%a%%b%%c/1000
if %memUsg% lss %memThreshold%

rem :: is the same ::
if 148 lss 450000 ...  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.