Answer the question
In order to leave comments, you need to log in
How to kill a given process at a specific time in Windows via CMD?
Tell me how to kill a given process at a specific time in Windows through CMD? For example at 05:00 am.
Windows schedulers are not suitable.
You need something like taskkill for a given time, so that every day at 5 in the morning it kills the process.
Answer the question
In order to leave comments, you need to log in
With a bit of "cutting". Check the variable ttt in the if statement and write with a space for the time where the hour is displayed with one character.
@echo off
:loop
timeout /t 60 /nobreak
call set ttt=%time:~0,-6%
if "%ttt%"==" 5:00" (goto :time) else (goto :loop)
:time
taskkill /f /im prog.exe
goto :loop
A strange requirement, the task scheduler is ideal for such tasks, it even allows you to display the window interactively (there is a checkbox in the settings).
You count how long in seconds the time you need will be (for example, after two hours - 3600 * 2 = 7200 the required time will come, then run once a day - 3600 * 24 = 86400), and write the following cmd file:
ping localhost -n 7200 > nul
:loop
taskkill /f /im myprog.exe
ping localhost -n 86400 > nul
goto :loop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question