Automatically close program at a scheduled time each day

16

8

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

user8407

Posted 2009-12-02T04:10:44.810

Reputation:

Answers

25

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

John T

Posted 2009-12-02T04:10:44.810

Reputation: 149 037

2Is there a way to do it without /f? I want the program to be able to handle its stuff when closing instead of killing it. – Bowi – 2018-06-26T15:40:51.600

1No need to put this in a batch file. Just set "Program/script" to: taskkill, and set "Add arguments" to: /f /im programname.exe – Alan L – 2018-11-12T03:59:18.600

@Bowi You can do it without /f but it might not actually close, if the program asks you to save files, etc. But you could do it nicely first and then force it afterward – endolith – 2019-08-06T15:34:33.680

2

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 http://technet.microsoft.com/en-us/library/bb491071.aspx.

TASKLIST list the applications that are running(type TASKLIST /? for help), but I don't know of a way to combine this 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(I don't really use windows so I never bother learning to much).

JC

Posted 2009-12-02T04:10:44.810

Reputation:

1

In Windows 10, a note about the AT command:

The AT command has been deprecated. Please use schtasks.exe instead.

A complete 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.

User

Posted 2009-12-02T04:10:44.810

Reputation: 2 430

1

System Scheduler seems to match your needs. From the website:

System Scheduler is an excellent tool to schedule unattended running of applications, batch files, scripts and much more.

For anyone used to using MS Windows own Task Scheduler, or the older AT or WinAT commands, System Scheduler is an ideal and easy to use replacement, with more flexibility and features. System Scheduler runs totally independently of the MS Windows Task Scheduler and has no dependencies on it.

Also, you can schedule popup reminders so you'll never forget those important appointments and things to do. Reminders, tasks and other events can be set to run once or every minute, hour, day, week, month or year and several variations on these. Popup Reminders can be snoozed as required.

System Scheduler not only allows you to launch programs at scheduled times but also to send keypresses and mouseclicks to those programs. This allows you to not only schedule programs to run overnight or at the weekend but also get those programs to do useful things while unattended. A really powerful feature.

Finally, the Free vesion of System Scheduler also includes a Window Watcher feature. The program will check for the existence of a particular window and send keypresses or send the window a close signal to terminate running applications. Useful for triggering actions or handling error messages while you are away.

Matthew Hill

Posted 2009-12-02T04:10:44.810

Reputation: 11

1

AT 07:21AM /every:M,T,W,Th,F,S,Su taskkill /f /im PROGRAM.EXE

You can get the program name by going into task manager and clicking the "Processes" tab.

user3053446

Posted 2009-12-02T04:10:44.810

Reputation: 11