Windows 2012R2 Task Sheduler stops task after gpupdate

Alexander Georgievskiy 1 Reputation point
2020-07-18T17:49:59.71+00:00

Hi. I created group policy with scheduled task (Windows 7+ type). Scheduled task contains multiple commands, group policy applies to Server 2012R2.

After group policy update scheduled task creates and runs successfully, but after another group policy update task stops in the middle. Task Scheduler show me successful exit code, although half of commands in the task has not been called.

This behaviour present in all 3 cases: regular group policy update, gpupdate and gpupdate /force.

I suspect this is because group policy update replaced task in the middle of running, so my questions is:

  1. Is scheduled task stop-after-task-update behavior bug or feature?
  2. If this is feature, is there any workaround better than putting commands into script and calling this script from scheduled task?
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,770 questions
Windows Server 2012
Windows Server 2012
A Microsoft server operating system that supports enterprise-level management, data storage, applications, and communications.
1,532 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Fan Fan 15,291 Reputation points Microsoft Vendor
    2020-07-20T03:51:04.69+00:00

    Hi,
    Thanks for sharing here!
    Before going further, would you please confirm the following questions ?
    How long did the task take if you run it manually?Based on my understanding , if the group policy was not refreshed , the script can run successfully, right?
    How did you set the script for the task?Run on a scheduled time every day/week, or apply only once?
    Also, would you please tell how did you configure the following setting :create ,replace,update? i would like do a test to confirm if it will be the same result.
    12907-7201.jpg

    Best Regards,
    Fan


  2. Brecht Mo 6 Reputation points
    2021-03-15T14:45:22.953+00:00

    I think I have good results with the option "Apply Once and do not reapply".

    I no longer have the "task registration deleted" -> "task terminated" -> "task registered" happening at every Group Policy Update.
    This behaviour is especially an issue if you schedule an indifinite task to start running at boot.
    This task is terminated some seconds after it started when the boottime Group Policy update runs, rendering the option "at system startup" for the scheduled task completely unusable.

    I'm not sure what the difference is with the "create" option though.

    0 comments No comments