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

8,392

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.

Share:
8,392

Related videos on Youtube

Michael J Swart
Author by

Michael J Swart

Updated on September 18, 2022

Comments

  • Michael J Swart
    Michael J Swart over 1 year

    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>
    
    • squillman
      squillman over 10 years
      What kind of VPN connection are you using?
    • Michael J Swart
      Michael J Swart over 10 years
      It's a standard Windows VPN connection. No 3rd party VPN client involved.
    • kralyk
      kralyk over 10 years
      Is the VPN running under the same account as the scheduled task? Are you trying to run the task without being logged on or are you logged in to the desktop? Can you manually run it?
    • Michael J Swart
      Michael J Swart over 10 years
      Manually running the task works. A manual trigger appears to bypass the condition entirely. I'm the only user logged into the machine and the VPN is connected in my session.
    • Michael J Swart
      Michael J Swart over 10 years
      Yes, @user2196728 ... that's kind of the basis for the whole issue.
    • krisFR
      krisFR over 10 years
      And if you try to select the wired interface for "network connection is available", is the task runs ?
    • Michael J Swart
      Michael J Swart over 10 years
      @user2196728 - Yes, selecting a WiFi (or wired I'd assume) connection works fine. Task succeeds.
    • krisFR
      krisFR over 10 years
      Let's try a thing : from the pc where your task should run, start a "ping -t" to the pc at the other side of the vpn tunnel, and let the task run automatically. Fails ?
    • krisFR
      krisFR over 10 years
      Is the ping was replying ?
    • Michael J Swart
      Michael J Swart over 10 years
      @user2196728 - Yes, the ping worked fine.
    • krisFR
      krisFR over 10 years
      I've tried to reproduce the behaviour as far as i also have a vpn connection, but worked for me...what are your settings for execution constraints about "session should be open or not" and "execute with maximum rights" ? Sorry, i am French so my pc is setup for French language, i don't know exact traduction.... ;)
    • Michael J Swart
      Michael J Swart over 10 years
      @user2196728 - "execute with maximum rights" (Run with highest privileges) is unchecked. "session should be open or not" (Run whether user is logged on or not) is checked. I added the full task XML to my question so you can see all the settings. I may try deleting and recreating my VPN connection but I can't do that right now.
    • krisFR
      krisFR over 10 years
      Try to check "Run with highest privileges"....
    • Michael J Swart
      Michael J Swart over 10 years
      @user2196728 - No change.
    • krisFR
      krisFR over 10 years
      What is your OS at scheduler side ?