Windows Scheduled Task refuse to run

2

0

I am trying to setup a daily task (running CTest from a batch script). I have used the default GUI of my Vista Pro 32bits, and setup the following task:

> schtasks /query /tn "trunk nightly" /xml
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2014-04-17T11:44:43.2643714</Date>
    <Author>PC-de-optiplex3\voxxl</Author>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2014-04-17T05:00:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <RunLevel>HighestAvailable</RunLevel>
      <UserId>PC-de-optiplex3\voxxl</UserId>
      <LogonType>Password</LogonType>
    </Principal>
  </Principals>
  <Settings>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>true</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Dashboards\ctest_scripts\hpdesk_openjpeg.bat</Command>
      <WorkingDirectory>C:\Dashboards\ctest_scripts\</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

From the GUI, it tells me that the last run happened on the 24th, while today is the 28th, so clearly it runs properly for a couple of days and then stop. Is there a way to setup a daily windows tasks, that actually runs on daily basis ? My user has admin rights, has a password, and workstation is properly plugged (no power outage during the week end).

As can be seen from the XML output, the flag WakeToRun is properly set to true. From the power management system, I cannot however set the famous Allow wake timers (interface if in french but clearly the 4th parameters is missing, simply compare with this)

enter image description here

here is the same screenshot after I click on Change settings that are currently unavailable:

enter image description here

Clearly the code above does not make use of any UI at all at least it does not open anything when I right click 'execute' from the windows schedulers panel. It run smoothly when executed by hand.

It looks just as if a task cannot run when computer is asleep...

malat

Posted 2014-04-28T10:11:01.980

Reputation: 981

is it working when executed manualy (right click / start) ? can you test another time and see if it is OK when the computer is awake ? – Loïc MICHEL – 2014-05-05T13:54:23.543

Following on from @Kayasax's q, does the script have some UI interaction that won't work when the workstation is asleep ? – None – 2014-05-05T14:50:05.583

no UI interaction at all – malat – 2014-05-06T06:56:44.773

Set a start time for like 5 minutes from now then check your event logs. Could be a permissions issue for some reason or something else equally fun. Another thing I'd do to help troubleshoot: in the command that points to the script in schedtask add the line ">hpdesk_openjpeg_output.txt" to the end of that command. This would save the output to a text file as if you ran it straight from cmd - but using the scheduled task process which can sometimes cause fun behaviors you wouldn't catch otherwise. – Bradley Forney – 2014-05-06T12:55:56.057

Answers

1

You have to enable wake up timers in the power savings plan options:
Control Panel -> Power Options -> Change plan settings -> Change advanced power settings.
In the list, item Sleep, change Allow wake timers to Enable.

The GUI parameters for the scheduled task should include :

In the General tab:

  • Check Run whether user is logged in or not

In the Conditions tab:

  • Check Wake the computer to run this task.

If there is no Wake the computer to run this task checkbox, then most probably your BIOS or hardware do not support wake timers, which is why Windows will not display the option.

If that's the case, the only other idea I have is, if wake-on-LAN is supported, to maybe do the waking from another computer on the network.

harrymc

Posted 2014-04-28T10:11:01.980

Reputation: 306 093

Here is the documentation for Vista: http://support.microsoft.com/kb/929463 I do not see anything like what you described from my vista environment.

– malat – 2014-05-07T07:02:08.257

It would be easier to fire up the Task Scheduler and check. – harrymc – 2014-05-07T08:28:36.960

let me rephrase my intial comment into: after searching in my vista installation I do not see anything called "Allow wake timers". Furthermore I took an extra (afterward) step to check online if I could find it, and I found the above link to microsoft documention. – malat – 2014-05-07T11:00:16.700

I don't have Vista, but this link shows how to reach "Allow wake timers" on Vista, and it's effectively different from Windows 7. If this works for you, I'll add it in my answer.

– harrymc – 2014-05-07T11:20:39.067

I've added a screenshot (sorry it's in French) of what parameters I can change. 'Allow wake timers' is not among them. – malat – 2014-05-07T12:18:30.040

Pas de problème. You might be able make the change in the registry. See this answer (requires reboot). Is there anything in the BIOS about wake? Is Vista fully patched?

– harrymc – 2014-05-07T13:42:12.830

I am starting to think that your BIOS or hardware do not support wake timers, which is why Windows will not display the option. If that's the case, the only other idea I have is, if wake-on-LAN is supported, to maybe do the waking via another computer on the network. – harrymc – 2014-05-08T09:44:34.417

I am doing a wakeonlan ... from a linux machine and everything went well over the week end. thanks much for the trick ! – malat – 2014-05-12T08:46:08.953

0

If you're unable to get the task scheduler to work for you, and, your task is started from sleep or hibernation, have a look at WakeOnStandby. It's free and it just might provide what you're looking for.

rrirower

Posted 2014-04-28T10:11:01.980

Reputation: 642