Automatically close program at a scheduled time each day
Is there a way to automagically determine if a program is running and close it at scheduled time, say 3 am every day?
Maybe use task scheduler to close said application? if this is possible any direction would be appreciated.
Vista or Win7
Solution 1:
Many ways to go about doing this. A simple solution would be to simply use Task Scheduler to run a batch script like this at 3 am every day:
taskkill /f /im programname.exe
save as something like closeprograms.bat and substitute programname.exe with the name of the executable you wish to kill. Set Task Scheduler up to run this batch file whenever you want.
-
/f
means that it is forcefully terminated -
/im
precedes the "image name" = process name
Solution 2:
In Windows 10, a note about the AT command:
The AT command has been deprecated. Please use schtasks.exe instead.
A complete schtasks example (type this at a windows command prompt):
SCHTASKS /Create /SC DAILY /ST 03:00:00 /TN sometaskname /TR "taskkill /f /im TheProgramYouWantToStop.exe"
To kill a program once at a specified time (rather than daily):
SCHTASKS /Create /SC ONCE /ST 03:00:00 /TN sometaskname /TR "taskkill /f /im TheProgramYouWantToStop.exe"
You can check on the task with
SCHTASKS /Query /TN sometaskname
Note: The task will also appear in Computer Management->Task Scheduler->Task Scheduler Library with the name sometaskname
and you can edit or delete it there. Sometimes you'll need to press F5 to refresh the task list in computer management to be able to see the task.
Solution 3:
To schedule a program from the Windows command line use this command:
AT hours:minutes /every:date command
So if you want to schedule something for 3:00 AM every day.
AT 03:00 /evry:M,T,W,Th,F,S,Su "command"
For more help check AT /?
, CMD /?
and this page.
TASKLIST
lists the applications that are running (type TASKLIST /?
for help), but I don't know of a way to combine these two commands to get the result you want or if there is other way to do it; check the site above and google for batch files and VBScript.