Scheduling Tasks

Posted by: JBjorgen

Scheduling Tasks - 03/09/2003 14:37

Here's a question for you programming gurus...

I need to schedule a task to run in the Windows Task Scheduler programatically. I know under WinNT and Win2k you can just shell out to the AT command or use the NetSchedule api calls. Unfortunately, under WinXP (and I assume win2003 server), unless you have a user setup for the at tasks to run as, they won't run. They sit there in the list looking like they will run, but they won't.

To make matters worse, there doesn't seem to be an easy way to add them under Win98 or ME. (Maybe just copy in the .job file and make sure the Task Scheduler is running at startup in the registry?)

I don't mind popping up a dialog for them to enter the administrator username/pass if needed, but I need for the task to be scheduled and actually run. It has to be possible, Norton does it pretty seamlessly...

Anyone willing to give that one a stab?
Posted by: tfabris

Re: Scheduling Tasks - 03/09/2003 14:41

That's odd. You can't just have the task run under the system account like other services do?

Boy, XP must suck or something.
Posted by: JBjorgen

Re: Scheduling Tasks - 03/09/2003 14:45

I tried...AFAIK, you can't.
Posted by: Roger

Re: Scheduling Tasks - 03/09/2003 17:39

I'm not sure what you're saying. If I run through the wizard, it prompts me for a user ID to run the task as. Are you saying that you enter this and nothing happens, or what?

Or are you specifically having problems with adding tasks programatically? If so, how are you adding them? Scripting? VB, VC++? What?
Posted by: JBjorgen

Re: Scheduling Tasks - 04/09/2003 07:01

I'm specifially having problems adding them programatically.

I'll use any platform that works, but scripting, VB, or Delphi probably works best. I don't have a VC++ compiler, but I'm sure I could find someone to compile something for me if it came down to it.
Posted by: JBjorgen

Re: Scheduling Tasks - 09/09/2003 14:45

After some looking around, I found a Delphi/C++Builder component that allowed me to automate everything. If anyone is interested, you can find it here. I wrote it so that if they are running XP, I pop up a login box, otherwise, it can add the tasks transparently.