Control Windows 7 Scheduled Maintenance Behavior Through Group Policy

This week one of my customers send me the Microsoft support article KB978980 – Desktop Shortcuts disappear in Windows 7 and the request to make sure this wouldn’t happen to his clients. In short, if a user creates a shortcut that points to a location that isn’t available at the time when the weekly scheduled system maintenance task is running, the shortcuts are considered as broken and therefore automatically deleted.

In the support article Microsoft doesn’t really provide a fix to solve this problem but rather describes 2 workarounds that don’t sound feasible to me.

Method 1
Keep the number of broken shortcuts on your desktop to four or less.

Method 2
If you must have more than four broken shortcuts on your desktop, you can disable the System Maintenance troubleshooter.

Well I don’t think we can expect our users to start counting their potentially broken desktop shortcuts and turning off the system maintenance troubleshooter isn’t a good idea too, because the system maintenance task does more than checking for broken shortcuts. Before explaining how this behavior can be changed through Group Policy, let’s first have a look what is really happening here.  

Open the Task Scheduler (you can run Taskschd.msc to start the Task Scheduler) and open the Microsoft, Windows Library, then select the Diagnosis Task. As you can see, this Task by default runs once a week.

2010-11-07 14h42_13

Now let’s have a look what this Task really does.

2010-11-07 14h44_50

OK, a Custom Handler, that doesn’t tell us that much, but let’s be creative and just type “Maintenance” in the Start Menu Search bar and then we find “Perform recommended maintenance tasks automatically”. So let’s start that one, and hey that is the Troubleshooting Wizard.

2010-11-07 14h59_55

By the way, you can launch the system maintenance directly using the following command line: msdt -id MaintenanceDiagnostic

Now we know that this belongs to the Troubleshooting stuff that comes with Windows 7, those that have been looking at this earlier know that this is all stored under C:\Windows\Diagnostics and within the Diagnostics folder there is a Scheduled\Maintenance folder

2010-11-07 15h12_41

And there we find the scripts being executed during the scheduled system maintenance tasks. Because these are all PowerShell scripts, I first thought about just modifying these scripts so that they wouldn’t delete any of these broken shortcuts, but since these files are system protected that doesn’t sound like a good idea to me, at least not for enterprise clients, because if you then run SFC /SCANNOW, you’ll get errors reported. If you want to apply that script editing hack on your personal computer you find possible approaches here and here.

Good, now that we know where this all comes from, let’s jump over to the Group Policy management console. Under Computer Configuration \ Administrative Templates \ System \ Troubleshooting and Diagnostics we have a Scheduled Maintenance branch that holds the Group Policy Settings for the Scheduled Maintenance Behavior.

2010-11-07 15h39_28

If we enable this Setting, we can configure the Execution Level to Regular or Troubleshooting only. By the way, the help text talks about detection, troubleshooting and resolution, this corresponds to the “Regular” option.

2010-11-07 15h44_07

If we want to prevent scheduled system maintenance task from automatically deleting broken shortcuts we must configure the Execution Level to Troubleshooting only.

2010-11-07 15h40_51

To test this behavior, simply create more than 4 shortcuts on your desktop and then delete or copy away the underlying files these shortcuts point to. (Do not “move” the files, because that won’t break the shortcuts). Then run the scheduled task manually and you will notice that the shortcuts won’t be deleted automatically anymore. I also recommend to have a look at the event log under Application and Service Logs \ Microsoft \ Windows \ Diagnosis-Scheduled and notice the different logging depending on how you have configured the Group Policy Setting.

Logging when set to Troubleshooting only
2010-11-07 16h17_41

Logging when not configured or set to Regular
2010-11-07 16h17_16

When the Scheduled System Maintenance is configured to only detect issues, any issues are reported to the Action Center.

20 Replies to “Control Windows 7 Scheduled Maintenance Behavior Through Group Policy”

  1. hope this GPO works, deploing right now.
    Laptop users have been whining about this for months. At first i wouldn’ t believe them…but it now seems that this is a serious issue MS keeps on ignoring….

    Thanks for the tip.

  2. Tried it : FAIL !

    I followed your steps :

    GPO created and applied succesfully on the machine.

    Created 5 shortcuts on Desktop. Deleted 5 documents related to those. Then i executed msdt -id MaintenanceDiagnostic and launched it and….wait for it….wait for it….
    Nah it deleted them.

    Well at least there’s another method working but its not deployable.

    Try this script
    It worked but has to be run as administrator. Can’t be run as logon script you’ll get a permission error…too bad.

    Your method FAILED for me.

  3. Neeeko – using that command will ALWAYS search for broken shortcuts regardless of how you have the group policy set. This GPO is only for SCHEDULED occurrences of the System Maintenance troubleshooter, not INTERACTIVE occurrences. I just ran it and it found broken shortcuts.
    A better way of testing it would be to go in to Task Scheduler, browse Task Scheduler/Task Scheduler Library/Microsoft/Windows Library/Diagnosis then right-click the Scheduled task and select Run.

    That said, this works fine for me. Given, I am testing it as a local GPO (not on my domain; it’s busy season at my job and I dare-not make GPO changes now!), but it worked just fine. I still have five broken shortcuts on my desktop.
    The results, broken shortcuts included, are still be presented to the Action Center though. Easily remedied by turning off the Action Center.

    Thanks for the insight, Alex!

  4. Need some help. I have Windows 2008 Server SP2. I can not for the life of me find “Scheduled maintenance” under troubleshooting and diagnostics. Any help is appricated.

  5. @Josh L. I have a SBS 2011 box and I dont see the GPO object. Should I install RSAT on the server?


  6. I must be missing something too obvious here. You say to go to “Computer Configuration \ Administrative Templates \ System \ Troubleshooting and Diagnostics” in the GP Mgmt Console. When I expand Computer Configuration on a new/blank GP I only have the options of Policies and Preferences. If I expand Policies there is an Administrative Templates section, but it’s only showing me options for Microsoft Office 2010 programs.

    What am I doing wrong? Thanks for your help.

  7. Hmm, that is weird, if nothing is being shown it means that you have no poliy definition files locally nor on a central store, might that be the case ?

  8. Nice article. But how do I change these settings on a single computer (non group-policy). I can’t get beyond the step “Under Computer Configuration \ Administrative Templates \ System \ Troubleshooting and Diagnostics we have a Scheduled Maintenance branch that holds the Group Policy Settings for the Scheduled Maintenance Behavior. ”
    Thanks in advance.

  9. I have come back to this article several times over the last few months, I’m so glad I located simple step by step instructions WITH explanations. Today I am working on my own Win7 machine that’s started losing desktop icons! Thanks for a very useful article.

  10. This is not available in Windows 2012 Group Policy (FYI, I’m using Essentials…not sure about Standard and up)

Leave a Reply