views:

1058

answers:

4

I have a couple applications that I would like to be able to add scheduled tasks from within them. I've been Googling for how to add tasks in both XP and Vista. Apparently, Vista has a new Task Scheduler that is very different from the one in XP.

Does anybody know if there is a single API to tackle both of them, or do I have to code for both in my apps?

+3  A: 

I think you could use the Task Scheduler COM interface.

Also check out this project.

Brian R. Bondy
The linked interface (TS 2.0) is Vista-only. Dude needs to use the TS 1.0 interface which works on XP as well.
I think he's got the "use COM" part handled, it's like Mike F says, he wants to use a single interface for XP AND Vista. TS 2.0 is therefore a complete non-starter.
HitScan
OK, I wasn't sure if the same interface was used in Vista.
Brian R. Bondy
A: 

If I recall correctly, the initial release of Vista used the same API as XP.

Server 2008 is supposed to have a much improved scheduler. That would seem to indicate that the API has changed.

I mention 2008 because SP1 for Vista brought much of the code in line with Server 2008.

Good luck and I'll be watching other answers.

Brad Bruce
A: 

Ideally, you could use the interface on the OS you're currently running on. You could do this by having an XP and Vista version of your app, for instance.

But Vista is from Microsoft, so the old API is still there for programs to use. The simplest solution is to use the XP API for this version of your app, and require Vista, Server 2K8 or better in the next version or perhaps 2 versions from now and transition to the Task Scheduler 2.0 API then.

HitScan
A: 

Just as I suspected. I will have to code to two different APIs then. It will make maintenance harder, but not impossible. Just need to make sure that I put integration test that cover both cases.

hectorsosajr