Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Performance > Scheduler wakes, doesn't wait for task to end, then goes back to s

Reply
Thread Tools Display Modes

Scheduler wakes, doesn't wait for task to end, then goes back to s

 
 
Pete Furtado
Guest
Posts: n/a

 
      03-17-2007
I have a task to run an executable. I have it set to run whether the user is
logged in or not, run with the highest privileges, wake the computer to run
this task, stop the task if it runs longer than 8 hours. It runs at 1am. The
task wakes the computer up at 1am fine, starts the executable, then puts the
computer back to sleep without waiting for the executable (a VS2005 SP1 C#
program I created) to complete. When I wake the computer in the morning, the
executable resumes.

What is up with this? Why can't the task scheduler wait until the task it
spawned finishes? My vista installation was an upgrade from XP Pro. But I
created the task (several times) from scratch in Vista. I also recompiled the
executable in Vista.

I have also tried the task in both "Windows Server 2003, Windows XP, or
Windows 2000" mode and in "Windows Vista" mode.

This is a huuuuuge step backward for me. I would appreciate any help anyone
can offer for this.
 
Reply With Quote
 
 
 
 
cquirke (MVP Windows shell/user)
Guest
Posts: n/a

 
      03-20-2007
On Sat, 17 Mar 2007 07:10:10 -0700, Pete Furtado <Pete
> wrote:

>I have a task to run an executable. I have it set to run whether the user is
>logged in or not, run with the highest privileges, wake the computer to run
>this task, stop the task if it runs longer than 8 hours. It runs at 1am. The
>task wakes the computer up at 1am fine, starts the executable, then puts the
>computer back to sleep without waiting for the executable (a VS2005 SP1 C#
>program I created) to complete. When I wake the computer in the morning, the
>executable resumes.


>What is up with this? Why can't the task scheduler wait until the task it
>spawned finishes? My vista installation was an upgrade from XP Pro. But I
>created the task (several times) from scratch in Vista. I also recompiled the
>executable in Vista.


Is the PC set to "suspend" after some time of inactivity?

If so, turn that off - as that may cut in just because there's no
keyboard or mouse activity going on.

Are there any settings within the Task's properties to control this
sort of behavior?



>--------------- ---- --- -- - - - -

Saws are too hard to use.
Be easier to use!
>--------------- ---- --- -- - - - -

 
Reply With Quote
 
Pete Furtado
Guest
Posts: n/a

 
      03-20-2007
Thanks for the reply.

It is set to go into standby after 2 hours. But it seems to go right back to
sleep after spawning the task. My executable writes informational messages to
the event log and I see it writing messages for about 30 seconds to a minute,
then nothing. I'm assuming that is when the machine goes back into standby.

I will double-check this tonight, though, and change the power scheme to
just leave the machine on all night and see what happens.

I can't find any other settings in the task's properties other than what I
stated in my original post. If there's some "hidden" ones, I'm dying to find
out.

I'll update this thread tomorrow with the results.

Thanks again.

"cquirke (MVP Windows shell/user)" wrote:

> On Sat, 17 Mar 2007 07:10:10 -0700, Pete Furtado <Pete
> > wrote:
>
> >I have a task to run an executable. I have it set to run whether the user is
> >logged in or not, run with the highest privileges, wake the computer to run
> >this task, stop the task if it runs longer than 8 hours. It runs at 1am. The
> >task wakes the computer up at 1am fine, starts the executable, then puts the
> >computer back to sleep without waiting for the executable (a VS2005 SP1 C#
> >program I created) to complete. When I wake the computer in the morning, the
> >executable resumes.

>
> >What is up with this? Why can't the task scheduler wait until the task it
> >spawned finishes? My vista installation was an upgrade from XP Pro. But I
> >created the task (several times) from scratch in Vista. I also recompiled the
> >executable in Vista.

>
> Is the PC set to "suspend" after some time of inactivity?
>
> If so, turn that off - as that may cut in just because there's no
> keyboard or mouse activity going on.
>
> Are there any settings within the Task's properties to control this
> sort of behavior?
>
>
>
> >--------------- ---- --- -- - - - -

> Saws are too hard to use.
> Be easier to use!
> >--------------- ---- --- -- - - - -

>

 
Reply With Quote
 
Adam
Guest
Posts: n/a

 
      03-22-2007
> I will double-check this tonight, though, and change the power scheme to
> just leave the machine on all night and see what happens.
>
> I can't find any other settings in the task's properties other than what I
> stated in my original post. If there's some "hidden" ones, I'm dying to
> find
> out.


Hi Pete,

Did you find a sollution to this? I'm having the same problem, although
only with a batch file which backs up some files. It normally takes around
15 to 20 minutes to run, but I can see from the event log that although the
Vista machine wakes up fine, it goes back into standby after about 7 or 8
minutes. My power settings tell the PC to go into standby after 1 hour.

I can't see a "keep machine awake while running task" option in the task
scheduler, which is exactly what I want.

A.

 
Reply With Quote
 
Pete Furtado
Guest
Posts: n/a

 
      03-22-2007
STILL NO LUCK!!!!

This is just unbelievable to me! You would think that with all the talk
about power saving and global warming, the LEAST that Microsoft could do
would be to make a task scheduler that actually allows you to leave your
computer in standby mode and only wake up to run a job or two and then go
back to sleep. They had it right in XP pro, before I upgraded my machine to
Visita this stuff worked flawlessly in XP Pro.

Unless I find an answer to this, I won't be upgrading my Media Center 2005
box to Vista, because I have that box in standby 20 hours a day and waking
up and recording, etc.

Okay, now that my ranting is done, I just say that if I find anything out,
I'll post it here. And if anyone has an answer to this, please let us know!

Thanks. Pete

"Adam" wrote:

> > I will double-check this tonight, though, and change the power scheme to
> > just leave the machine on all night and see what happens.
> >
> > I can't find any other settings in the task's properties other than what I
> > stated in my original post. If there's some "hidden" ones, I'm dying to
> > find
> > out.

>
> Hi Pete,
>
> Did you find a sollution to this? I'm having the same problem, although
> only with a batch file which backs up some files. It normally takes around
> 15 to 20 minutes to run, but I can see from the event log that although the
> Vista machine wakes up fine, it goes back into standby after about 7 or 8
> minutes. My power settings tell the PC to go into standby after 1 hour.
>
> I can't see a "keep machine awake while running task" option in the task
> scheduler, which is exactly what I want.
>
> A.
>
>

 
Reply With Quote
 
Adds
Guest
Posts: n/a

 
      03-23-2007
Humm... It's certainly annoying.

I haven't been able to find out anything about it, dispite spending several
hours on Google. All I've found so far is

http://technet.microsoft.com/en-us/w.../aa906020.aspx

Which says "Task Scheduler wakes the machine to run the tasks and allows it
to return to standby or hibernation when the task is complete, saving energy
while still ensuring that critical tasks run on time."

And our systems obviosuly aren't working like that - They're returning to
standby mode before the task completes.

I'll keep looking, and will post back here if I find anything.

A.




"Pete Furtado" <> wrote in message
news:E812FAC5-A81A-4D72-A291-...
> STILL NO LUCK!!!!
>
> This is just unbelievable to me! You would think that with all the talk
> about power saving and global warming, the LEAST that Microsoft could do
> would be to make a task scheduler that actually allows you to leave your
> computer in standby mode and only wake up to run a job or two and then go
> back to sleep. They had it right in XP pro, before I upgraded my machine
> to
> Visita this stuff worked flawlessly in XP Pro.
>
> Unless I find an answer to this, I won't be upgrading my Media Center 2005
> box to Vista, because I have that box in standby 20 hours a day and
> waking
> up and recording, etc.
>
> Okay, now that my ranting is done, I just say that if I find anything out,
> I'll post it here. And if anyone has an answer to this, please let us
> know!
>
> Thanks. Pete
>
> "Adam" wrote:
>
>> > I will double-check this tonight, though, and change the power scheme
>> > to
>> > just leave the machine on all night and see what happens.
>> >
>> > I can't find any other settings in the task's properties other than
>> > what I
>> > stated in my original post. If there's some "hidden" ones, I'm dying to
>> > find
>> > out.

>>
>> Hi Pete,
>>
>> Did you find a sollution to this? I'm having the same problem, although
>> only with a batch file which backs up some files. It normally takes
>> around
>> 15 to 20 minutes to run, but I can see from the event log that although
>> the
>> Vista machine wakes up fine, it goes back into standby after about 7 or 8
>> minutes. My power settings tell the PC to go into standby after 1 hour.
>>
>> I can't see a "keep machine awake while running task" option in the task
>> scheduler, which is exactly what I want.
>>
>> A.
>>
>>



 
Reply With Quote
 
Adds
Guest
Posts: n/a

 
      03-29-2007

"Adds" <> wrote in message
news:...
> Humm... It's certainly annoying.


I think I might have found away around this, although not ideal.

In my batch file, I'm running powercfg first to set the PC into "High
Performance" mode (powercfg /? will give the options). I then set it back
to my normal power mode after the batch file has complete.

I have to admit that I haven't given it long enough to test properly, but it
appears to work.

Not ideal I know, but at least it might be a work around.

A.


 
Reply With Quote
 
Pete Furtado
Guest
Posts: n/a

 
      04-08-2007


"Adds" wrote:

>
> "Adds" <> wrote in message
> news:...
> > Humm... It's certainly annoying.

>
> I think I might have found away around this, although not ideal.
>
> In my batch file, I'm running powercfg first to set the PC into "High
> Performance" mode (powercfg /? will give the options). I then set it back
> to my normal power mode after the batch file has complete.
>
> I have to admit that I haven't given it long enough to test properly, but it
> appears to work.
>
> Not ideal I know, but at least it might be a work around.
>
> A.
>
>
>


Interesting idea. I got so disgusted with this problem that I gave up for a
while.

Anyway, how has it worked for you? I will try this myself in the next couple
of days. Thanks!
Pete

 
Reply With Quote
 
clayga
Guest
Posts: n/a

 
      07-01-2007
I've got two Vista machines doing this as well. Using a batch file to switch
to high performance mode where sleep is set to "never" before the task runs
doesn't fix the problem. Both machines drop back to sleep within a minute or
two of task start regardless of power mode. I originally ran across this
problem with defrag and thought it might have to do with the fact that defrag
does low-priority (background) I/O, but I've reproduced the problem with
several different disk I/O intensive tasks that use normal priority I/O so
that's not it (and just in case anybody is wondering: removing the -i switch
on defrag has no affect either).

Looks like a Vista power management bug to me. Windows has certainly had
it's fair share of these over the years. Lets hope the bug gets fixed in SP1
or (hopefully) sooner in an update.

Clayton Gautier

"Pete Furtado" wrote:

>
>
> "Adds" wrote:
>
> >
> > "Adds" <> wrote in message
> > news:...
> > > Humm... It's certainly annoying.

> >
> > I think I might have found away around this, although not ideal.
> >
> > In my batch file, I'm running powercfg first to set the PC into "High
> > Performance" mode (powercfg /? will give the options). I then set it back
> > to my normal power mode after the batch file has complete.
> >
> > I have to admit that I haven't given it long enough to test properly, but it
> > appears to work.
> >
> > Not ideal I know, but at least it might be a work around.
> >
> > A.
> >
> >
> >

>
> Interesting idea. I got so disgusted with this problem that I gave up for a
> while.
>
> Anyway, how has it worked for you? I will try this myself in the next couple
> of days. Thanks!
> Pete
>

 
Reply With Quote
 
clayga
Guest
Posts: n/a

 
      08-12-2007
In case anyone still cares about this issue, I've come up with a work-around.
It involves the Win32 API function SetThreadExecutionState (kernel32.dll).
You can find the details on the web, but basically, Windows can be forced to
stay awake while a process runs by sandwiching the process between two
SetThreadExecutionState calls (with different arguments for the calls). The
sandwiching can be implemented in a variety of ways - I chose to create an
executable, named StayAwakeExec in VB 2005 Express Edition (free) that does
the following:

1) makes the first call to SetThreadExecutionState to block sleep
2) spawns an executable passed in as a command line argument
3) makes the second call to SetThreadExecutionState to allow sleep after
the spawned executable exits

Note that the "after the spawned executable exits" part of Step 3 is
implemented by calling Process.WaitForExit() for the spawned executable.

I've successfully used StayAwakeExec to spawn defrag.exe with a task that
wakes the computer at 1AM. The computer now wakes, runs defrag to
completion, and then goes back to sleep immediately after the defrag finishes
(as verified by the system log file).

I was hoping that the latest Vista performance and reliability patches
(KB938194 and KB938979) would fix the bug, design flaw - whatever you want to
call it - that made this workaround necessary, but alas, twas not so. I
tested both my systems after installing these patches and Vista still falls
asleep almost exactly 2 minutes after a scheduled task wakes the computer
regardless of whether the task is done. My expectation (and I'm pretty sure
most people would agree) is if you check the "Wake the computer to run this
task" checkbox on the Conditions tab in Task Schedular, Windows should stay
awake until the task is complete. It should be a simple matter for an MS
developer to add to the task schedular service the sandwiching calls to
SetThreadExecutionState to prevent sleep if "Wake the computer to run this
task" is checked. Hopefully SP1 will have this fix.


"clayga" wrote:

> I've got two Vista machines doing this as well. Using a batch file to switch
> to high performance mode where sleep is set to "never" before the task runs
> doesn't fix the problem. Both machines drop back to sleep within a minute or
> two of task start regardless of power mode. I originally ran across this
> problem with defrag and thought it might have to do with the fact that defrag
> does low-priority (background) I/O, but I've reproduced the problem with
> several different disk I/O intensive tasks that use normal priority I/O so
> that's not it (and just in case anybody is wondering: removing the -i switch
> on defrag has no affect either).
>
> Looks like a Vista power management bug to me. Windows has certainly had
> it's fair share of these over the years. Lets hope the bug gets fixed in SP1
> or (hopefully) sooner in an update.
>
> Clayton Gautier
>
> "Pete Furtado" wrote:
>
> >
> >
> > "Adds" wrote:
> >
> > >
> > > "Adds" <> wrote in message
> > > news:...
> > > > Humm... It's certainly annoying.
> > >
> > > I think I might have found away around this, although not ideal.
> > >
> > > In my batch file, I'm running powercfg first to set the PC into "High
> > > Performance" mode (powercfg /? will give the options). I then set it back
> > > to my normal power mode after the batch file has complete.
> > >
> > > I have to admit that I haven't given it long enough to test properly, but it
> > > appears to work.
> > >
> > > Not ideal I know, but at least it might be a work around.
> > >
> > > A.
> > >
> > >
> > >

> >
> > Interesting idea. I got so disgusted with this problem that I gave up for a
> > while.
> >
> > Anyway, how has it worked for you? I will try this myself in the next couple
> > of days. Thanks!
> > Pete
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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
Task Scheduler repeat task duration bug? sm02463 Windows Vista General Discussion 4 12-06-2008 06:40 PM
Task scheduler returns an error : the task image is corrupt ortamp Jean-David Windows Vista Performance 2 05-03-2008 02:02 PM
Task Scheduler wakes up, but goes back to sleep Cue8Chalk Windows Vista General Discussion 0 08-28-2007 04:46 PM
task scheduler doesn't start delayed task wuschba Windows Vista General Discussion 6 07-26-2007 08:06 AM
Task scheduler problem : task do not close Junkyard Engineer Windows Vista General Discussion 0 06-07-2007 01:51 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59