PC Review


Reply
Thread Tools Rate Thread

Creating a scheduled task that deletes itself after it's done

 
 
Roy Assaly
Guest
Posts: n/a
 
      29th Nov 2007
Hi guys,

I want to create a task that executes one time, let's say 2 minutes
from now, and after the task has completed, it deletes itself.

The problem is, it says that I need an expiration date to specify when
the task gets deleted. I have no idea how long my task will take, so
how can possible put an expiration date?!?

example:

Current time: 1:00 pm
Create a task to run at 1:02 pm
Task may take 20 to 30 minutes to run.
I want the task to delete itself immediately whether it took 20 or 30
minutes.

I don't want to put 1:40 pm as the expiration time, but I have no idea
how long it takes.
If I put it at a less time, like 1:10 pm, then the task deletes itself
before whatever job it had to do completed!

Please help!!! I've been struggling for hours on this.
 
Reply With Quote
 
 
 
 
Tom Porterfield
Guest
Posts: n/a
 
      29th Nov 2007
Roy Assaly wrote:
> Hi guys,
>
> I want to create a task that executes one time, let's say 2 minutes
> from now, and after the task has completed, it deletes itself.
>
> The problem is, it says that I need an expiration date to specify when
> the task gets deleted. I have no idea how long my task will take, so
> how can possible put an expiration date?!?
>
> example:
>
> Current time: 1:00 pm
> Create a task to run at 1:02 pm
> Task may take 20 to 30 minutes to run.
> I want the task to delete itself immediately whether it took 20 or 30
> minutes.
>
> I don't want to put 1:40 pm as the expiration time, but I have no idea
> how long it takes.
> If I put it at a less time, like 1:10 pm, then the task deletes itself
> before whatever job it had to do completed!
>
> Please help!!! I've been struggling for hours on this.


I'll have to test this on a Vista machine, but once a scheduled task
starts a process, that process should complete even if the task is
deleted while the process is still running. So you should be able to
schedule the task to run a 1:02 pm and the expire the task at 1:03 pm
and the process that the task started should still run to completion.
--
Tom Porterfield
 
Reply With Quote
 
Roy Assaly
Guest
Posts: n/a
 
      29th Nov 2007
> I'll have to test this on a Vista machine, but once a scheduled task
> starts a process, that process should complete even if the task is
> deleted while the process is still running. So you should be able to
> schedule the task to run a 1:02 pm and the expire the task at 1:03 pm
> and the process that the task started should still run to completion.
> --
> Tom Porterfield


Hi Tom,

You are right, the process is completing. However, I just wish that
the Task doesn't delete itself until the process has completed.

For example, if the process takes 15 mintues, and task is set to be
deleted in 10 minutes, the task gets deleted and the process remains
running in the background. We now no longer have any idea if the
process completes in 15 or hangs since no task is attached to it
anymore.

Thanks.

Roy
 
Reply With Quote
 
Roy Assaly
Guest
Posts: n/a
 
      29th Nov 2007
On Nov 29, 3:53 pm, Roy Assaly <royass...@gmail.com> wrote:
> > I'll have to test this on a Vista machine, but once a scheduled task
> > starts a process, that process should complete even if the task is
> > deleted while the process is still running. So you should be able to
> > schedule the task to run a 1:02 pm and the expire the task at 1:03 pm
> > and the process that the task started should still run to completion.
> > --
> > Tom Porterfield

>
> Hi Tom,
>
> You are right, the process is completing. However, I just wish that
> the Task doesn't delete itself until the process has completed.
>
> For example, if the process takes 15 mintues, and task is set to be
> deleted in 10 minutes, the task gets deleted and the process remains
> running in the background. We now no longer have any idea if the
> process completes in 15 or hangs since no task is attached to it
> anymore.
>
> Thanks.
>
> Roy


SOLVED!

Hi Tom,

I did it anagrammatically. I checked if the LastRunResult was 0, if
it was, then it means the task was run successfully, and I simply
delete the task. I poll the computer every 5 seconds. Initially,
when a task is freshly created, the LastRunResult is 1.

Thanks for your effort. I appreciate it
 
Reply With Quote
 
Tom Porterfield
Guest
Posts: n/a
 
      30th Nov 2007
Roy Assaly wrote:
> I did it anagrammatically. I checked if the LastRunResult was 0, if
> it was, then it means the task was run successfully, and I simply
> delete the task. I poll the computer every 5 seconds. Initially,
> when a task is freshly created, the LastRunResult is 1.
>
> Thanks for your effort. I appreciate it


Glad to hear you came up with a solution, and thanks for posting it back
here so others can benefit as well.
--
Tom Porterfield
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating a scheduled task. Neil Microsoft VB .NET 4 10th Jul 2006 02:31 PM
Error creating scheduled task =?Utf-8?B?QnJpYW4gRWxraW5z?= Windows XP General 4 11th Jan 2006 11:18 PM
Help Creating A Scheduled Task MDB Microsoft Dot NET Compact Framework 2 8th Feb 2005 11:56 AM
Creating a scheduled task =?Utf-8?B?Y2Ri?= Microsoft Access Getting Started 3 27th Jan 2005 06:51 PM
VB.NET Code for creating a scheduled task (.job) Max Microsoft VB .NET 8 2nd May 2004 01:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:36 PM.