The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Periodic execution under Windows

How does an application register itself so that Windows will execute it on a periodic basis -- e.g. nightly?  I notice a lot of applications that do this run something in the background, but that strikes me as very wasteful.
Michael B
Monday, August 08, 2005
You can set up a scheduled task.  There is a control panel for it.

Also there is the command AT.  On the cmd prompt, type 'at /?' for more info.
Michael H. Pryor Send private email
Monday, August 08, 2005
Windows Task Scheduler.

In my version (XP Pro) it's in the control panel as "Scheduled Tasks".
Sgt.Sausage Send private email
Monday, August 08, 2005
Has anyone had any success getting the Windows task scheduler to work reliably? My experience has been that it works long enough to convince you that it is working, then mysteriously stops. (Windows 2000 - is XP better?)

From memory opening the task and reentering the password for the account makes it work again for a while. The password for the account hasn't changed. If anyone can explain what I need to do to make this work it would be very helpful.
Andrew Rowley Send private email
Monday, August 08, 2005
There is a small gotcha in the scheduler in windows, which had me stumped until I discovered it (with an accompanying "d'oh!" noise and feeling of foolishness).

Hidden in the 'settings' panel (at least on the flavour of windows that I am using), you get to tell it when to just stop running your app. Some bozo in the company I was working at at the time had set this to about a hour, I think, which wasn't enough for some tasks I was trying to run. The result was that it just stopped. It blinked out of existance, as though consumed in a flurry of strange and esoteric atomic particles. No closing down nicely, no flushing buffers, no entering 'finally' blocks, no return codes reported to the invoking batch file. Just gone. Log messages half written, and very perplexing.

Anyway, Andrew, I'm not sure from your mail, but that might have something to do with it working "long enough to convince you that it is working, then mysteriously [stopping]".
Tuesday, August 09, 2005
It sometimes does work, but in a different windows station. An invisible Windows station. So it may happen that your task actually is running, but no windows/consoles are open on the screen.
Ori Berger
Tuesday, August 09, 2005
Andrew, there is a timer overflow that happens around 47 days of uptime, so you may need to reboot monthly like the FAA computers. MSMQ, in earlier versions, had a timer overflow around 1.5 weeks (I don't know if those have been fixed either). Also, if the process has an error of any sort, it pops up a dialog box to an invisible desktop that you cannot get to (and thus cannot click "OK"). Which can lead to the appearance of running while it is sitting there going "Click OK to continue" to an invisible desktop.
Tuesday, August 09, 2005
My problem is that if I schedule a task for once a day it runs OK for the first few days but then stops.

My gut feeling is that if the computer is not turned on at the scheduled time, it won't run again until the password is re-entered into the scheduler. I haven't spent enough time on it to actually confirm this though.
Andrew Rowley Send private email
Tuesday, August 09, 2005
Thanks for all who replied.

My analysis follows.

Scheduler is kind of useless, because:
    a) it runs applications as SYSTEM, and not the user who scheduled the task
    b) is disabled by default (probably because of security concerns in a)

Someone tried to fix gaping security hole of scheduler by allowing you to execute tasks as a user, however:

    c) it's impossible to schedule a task to run as a user that's not currently logged in, unless
    d) you must the user's password to run a command as that user at a later date; prompting a user and storing their password creeps me out
    e) see b

So I'll do what I didn't want to do: run hidden forever, keep polling to see if it's time to execute, hope the user isn't too confused by their task not running if they're not logged in.
Michael B
Thursday, August 18, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz