![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Scheduler wakes, doesn't wait for task to end, then goes back to s 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. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Scheduler wakes, doesn't wait for task to end, then goes back to s On Sat, 17 Mar 2007 07:10:10 -0700, Pete Furtado <Pete Furtado@discussions.microsoft.com> 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! >--------------- ---- --- -- - - - - |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Scheduler wakes, doesn't wait for task to end, then goes back 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 > Furtado@discussions.microsoft.com> 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! > >--------------- ---- --- -- - - - - > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Scheduler wakes, doesn't wait for task to end, then goes back "Adds" <adds21@yahoo.com> wrote in message news:eOy6ReVbHHA.1508@TK2MSFTNGP06.phx.gbl... > 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. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Scheduler wakes, doesn't wait for task to end, then goes back "Adds" wrote: > > "Adds" <adds21@yahoo.com> wrote in message > news:eOy6ReVbHHA.1508@TK2MSFTNGP06.phx.gbl... > > 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 |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Scheduler wakes, doesn't wait for task to end, then goes back 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" <adds21@yahoo.com> wrote in message > > news:eOy6ReVbHHA.1508@TK2MSFTNGP06.phx.gbl... > > > 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 > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Scheduler wakes, doesn't wait for task to end, then goes back 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" <adds21@yahoo.com> wrote in message > > > news:eOy6ReVbHHA.1508@TK2MSFTNGP06.phx.gbl... > > > > 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 > > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Scheduler wakes, doesn't wait for task to end, then goes back Thanks for the tip, clayga! That works most of the time on my pc. I did basically the same thing, i have a separate executable calling SetThreadExecutionState, and then I just call that first from vbscript, do anything else I need to do via vbscript, then kill that task and exit the script. Sorry for the late reply. I couldn't log into this site for a while for some reason. I still have more problems with this stupid Vista task scheduler. Sometimes tasks just don't run. Yes, yes, i know all the options to wake computer to run this task, and run whether user is logged on or not. They just did a really, really bad implementation of the task scheduler in Vista. I hope they fix it one of these days. Thanks again! Pete Furtado "clayga" wrote: Quote: > 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: > Quote: > > 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: > > Quote: > > > > > > > > > "Adds" wrote: > > > > > > > > > > > "Adds" <adds21@xxxxxx> wrote in message > > > > news:eOy6ReVbHHA.1508@xxxxxx > > > > > 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 > > > |
My System Specs![]() |
| | #9 (permalink) |
| Vista Ultimate 32bit | Re: Scheduler wakes, doesn't wait for task to end, then goes back to s Having the same problem with Vista Ultimate 32 bit, but that vb script stuff is way over my head... |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Task Scheduler Compatibility module task status update failed | General Discussion | |||
| Task Scheduler Error-task image corrupt or has been tampered with User_Feed_Synchroni | General Discussion | |||
| Schedule a task with Vista task Scheduler wakes up computer and mo | Vista General | |||
| Task scheduler returns an error : the task image is corrupt ortamp | Vista performance & maintenance | |||
| Task Scheduler wakes up, but goes back to sleep | Vista General | |||