Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Group Policy Preferences scheduled task not applying: event 4098 "did not apply because it failed with error code" 0x80070005 Access is denied

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

A user-side Group Policy Preferences (GPP) scheduled task that does not take effect, together with an event 4098 warning that Microsoft's page shows as "did not apply because it failed with error code '0x80070005 Access is denied.'" in the trace log, has one cause in Microsoft's page. The item was set to "Run in logged-on user's security context (user policy option)", which a user GPP Scheduled Tasks item was not designed to do.

Microsoft's fix is to leave that Common option off and to choose the account the task runs under on the General tab. Read the event first, so you know it is this fault and not another cause behind the same event ID. The GPP trace log gives more detail once tracing is switched on, which is a change of its own.

What the error means

Group Policy Preferences are settings applied by client-side extensions, with item-level control. A preference item can be a scheduled task. Microsoft's page describes the faulty case: you configure the user item

User Configuration\Preferences\Control Panel Settings\Scheduled Tasks\New\"Scheduled Task (Windows Vista and later)"

and, on the Common tab, select "Run in logged-on user's security context (user policy option)". After the policy is applied to a user, the preference item does not take effect.

Microsoft's page states the cause: "The User GPP Scheduled Tasks item wasn't designed to run under the currently logged on users security context AND must be applied in the default system security context."

The event is logged in the Application log. Microsoft's list of Group Policy Preferences events gives the message for event 4098 (0x1002) with severity Warning: "The %1 '%2' preference item in the '%3' Group Policy object did not apply because it failed with error code '%4'". The same list has event 8192 (0x2000) with the same wording. Its success message is event 4096: "The %1 '%2' preference item in the '%3' Group Policy object applied successfully."

Microsoft's events page also says informational events are written only when the relevant Group Policy settings are enabled. The path for those settings is Computer Configuration\Policies\Administrative Templates\System\Group Policy\Logging and tracing.

Microsoft's scheduled-task page describes a Windows Server 2008 or 2008 R2 domain in its example, and both pages say "Applies to: Supported versions of Windows Server". They do not say whether newer releases behave the same way.

Likely causes

Cause What you see How to confirm
The Common tab option "Run in logged-on user's security context (user policy option)" is on for a user scheduled task item The item is not created; event 4098 with 0x80070005 Access is denied. Open the preference item and read the Common tab
A different error code in the same event Event 4098 with another code Read the code in the event; this fault is 0x80070005 only
A targeting item failed Events 4105 or 4106, which Microsoft's list words as a targeting item that failed Read the event text

Prove the cause before changing anything

All of these only read.

  1. In the Application log on the computer, find the warning from the source "Group Policy Scheduled Tasks" with event ID 4098. Microsoft's list gives the source names, and "Group Policy Scheduled Tasks" is one of them. The event names the preference item and the Group Policy object.
  2. Read the error code in the message. This fault is 0x80070005 Access is denied. and not another code.
  3. Open the item in Group Policy Management. Go to the preference item path above and read the Common tab: is "Run in logged-on user's security context (user policy option)" selected?
  4. Read the General tab. Microsoft says that under Security Options the field "When running the task, use the following user account:" is where the security context for the task should be set, and that by default it is %LogonDomain%\%LogonUser%.

For more detail, Microsoft says you can enable Group Policy tracing for the GPP Scheduled Tasks extension. Switching it on is a change, covered under Fix. The setting is Computer Configuration\Policies\Administrative Templates\System\Group Policy\Logging and Tracing\Configure Schedulled Tasks preference logging and tracing, with the word "Schedulled" spelled that way on Microsoft's page. Once it is configured, the log is created at:

%SystemDrive%\ProgramData\GroupPolicy\Preference\Trace\User.log

Microsoft shows the trace lines for the fault, including WorkItem.Init [hr = 0x80070005 "Access is denied."] and the "did not apply because it failed with error code '0x80070005 Access is denied.'" event line.

Example (illustrative): at contoso.com.au a policy for the Finance OU is meant to create a task at sign-in on rds01 that opens a shared spreadsheet. Users' sessions never show the task. The Application log on rds01 holds event 4098 for the preference item with 0x80070005 Access is denied. The item's Common tab has "Run in logged-on user's security context (user policy option)" selected. That is the cause Microsoft names.

Fix

Microsoft's resolution has two parts: "don't enable the Run in logged-on user's security context (user policy option) Common option when configuring user GPP Scheduled Tasks items", and set the account the task runs under in General > Security Options.

Before you change the item, write down its Common tab and General tab settings, and which Group Policy object holds it. The console gives no export of one preference item on Microsoft's page, so the written copy is your saved copy.

Risk: the next step edits a preference item inside a Group Policy object. Every user and computer in that object's scope takes the change at their next policy refresh, so a wrong edit reaches all of them. Clearing the option changes the security context under which the item is processed, and the task then runs under the account named on the General tab.

Edit the item:

  1. Open the Group Policy object in Group Policy Management and edit it.
  2. Go to User Configuration\Preferences\Control Panel Settings\Scheduled Tasks and open the item.
  3. On the Common tab, clear "Run in logged-on user's security context (user policy option)".
  4. On the General tab, under Security Options, set "When running the task, use the following user account:" to the account the task should run as.
  5. Save the item.

To undo it, open the same item, set the Common tab and the General tab back to the values you wrote down, and save.

Microsoft's page gives no steps for choosing the account on the General tab beyond naming the field and its default, and it does not say which account is right for your task. That is a decision for whoever owns the task.

To get the trace log, tracing has to be switched on, which is a change of its own. Before you change it, note the setting's current value (for example Not configured).

Risk: the next change turns on logging in a Group Policy object, which writes a log file on each computer in its scope. The file is User.log and can contain the names of preference items and Group Policy objects.

Set the tracing setting named on Microsoft's page to enabled in a Group Policy object that applies to a test computer. To undo it, set the policy back to the value you noted.

Microsoft's page names one log file. If User.log does not exist at the path below, there is nothing to save or delete; stop here. When you no longer need it, first save a copy under a new name. In an elevated Command Prompt, the /-Y switch makes the copy ask before it overwrites; answer No if it asks:

copy /-Y "%SystemDrive%\ProgramData\GroupPolicy\Preference\Trace\User.log" "%UserProfile%\Documents\User-saved-1.log"

Use a new number instead of 1 if a saved file of that name already exists, so an earlier copy is never overwritten.

Risk: the next command deletes User.log, and del does not use the Recycle Bin. Anyone who still needs its trace lines loses them, and the saved copy is the only way back.

del "%SystemDrive%\ProgramData\GroupPolicy\Preference\Trace\User.log"

To undo it, copy the saved file back. /-Y asks before it overwrites a new User.log that tracing may have created since:

copy /-Y "%UserProfile%\Documents\User-saved-1.log" "%SystemDrive%\ProgramData\GroupPolicy\Preference\Trace\User.log"

Confirm the fix

  • Run a policy refresh on a test user's session by signing out and in, and read the Application log. Microsoft's events list gives event 4096 as the success message: "The %1 '%2' preference item in the '%3' Group Policy object applied successfully." The list gives it as Success; Microsoft's page says informational events are only logged when the relevant Group Policy settings are enabled.
  • Check the scheduled task exists on the target computer.
  • Read User.log if tracing is on: the 0x80070005 lines should be gone.

What to watch afterwards

  • New user scheduled-task items. Microsoft's advice applies to every one.
  • Events 4105 and 4106, which the events list words as a targeting item that failed.
  • Any other error code in event 4098, which this fix does not address, and the same wording in event 8192, which Microsoft lists separately.

Risks and limits

These steps have not been run or lab-tested.

Microsoft's page describes a Windows Server 2008 or 2008 R2 domain in its example and says "Supported versions of Windows Server". It gives no newer version range and no steps for the console beyond the paths above. Editing a Group Policy object reaches every user and computer in its scope.

Sources