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

R

Roy Assaly

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.
 
T

Tom Porterfield

Roy said:
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.
 
R

Roy Assaly

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.

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
 
R

Roy Assaly

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 :)
 
T

Tom Porterfield

Roy said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top