![]() |
|
Welcome to Vista Banter. You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to ask questions and reply to others posts, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact support. |
|
|||||||
| Performance and Maintainance of Windows Vista A forum for performance and maintenance tasks in Windows Vista. (microsoft.public.windows.vista.performance_maintainance) |
|
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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: 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 ... 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 |
|
|||
|
Having the same problem with Vista Ultimate 32 bit, but that vb script stuff is way over my head... -- Polo |
|
| Thread Tools | |
| Display Modes | |
|
|