Windows – Scheduled Task fails to start due to network connection condition even when connection is available

scheduled-taskwindowswindows-8.1

I have a scheduled task with a condition set to "Start only if the following network connection is available". I've selected my VPN connection.

However, even when my VPN is connected the task will fail to start.

Task Scheduler failed to start "\Backups\Test" task for user "MYDOMAIN\administrator". Additional Data: Error Value: 2147750692.

Task Scheduler could not start task "\Backups\Test" because the network was unavailable. User Action: Ensure the computer is connected to the required network as specified in the task. If the task does not require network presence, remove the network condition from the task configuration.

Any idea why it isn't detecting the network connection availability? I'm lost.

More details

  • This is a Windows VPN connection, no 3rd party VPN software involved.
  • I'm logged into the machine and logged onto the VPN when the task tries to run.
  • My VPN connection is definitely working, pings and such work fine.

Exported Task XML

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2013-12-10T19:46:08.1423901</Date>
    <Author>MYDOMAIN\administrator</Author>
    <Description>Upload backup files to the network.</Description>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2013-12-10T12:00:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
    <TimeTrigger>
      <StartBoundary>2013-12-11T12:54:01</StartBoundary>
      <Enabled>true</Enabled>
    </TimeTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>MYDOMAIN\administrator</UserId>
      <LogonType>Password</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>
    <NetworkSettings>
      <Name>My VPN Connection</Name>
      <Id>{3148EF2F-A10A-4A00-BB87-98A995247E4C}</Id>
    </NetworkSettings>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\upload-backup.cmd</Command>
    </Exec>
  </Actions>
</Task>

Best Answer

Late but better than never... I was dealing with the same issue and (at least in my case) it seems to be timing related. It seems that after you establish such VPN connection, it takes few seconds (usually between 5-10) before the task manager is able to determine that the related network connection is available.

So by experimenting a little I found the minimum delay with which the task is pretty much reliably started, then added 1 more second to the delay just to be sure and that's how I use it now. It isn't ideal since that delay isn't something that makes it really comfortable to use, but it really works.

So the main point is - try to delay the task execution a little.