If it seems like the desktop shortcuts on your Windows 7 keep disappearing, you're not hallucinating. Windows 7 automatically deletes broken and network shortcuts if there are too many. Here's how to stop Windows from throwing these (often still useful) shortcuts away.

If you have four or more "broken" desktop shortcuts (which includes shortcuts to disconnected network locations and shell folders), System Maintenance in Windows 7 will delete the shortcuts in its weekly maintenance. While Microsoft suggests keeping the number of these type of desktop shortcuts to four or less, or as an alternative, turning off System Maintenance altogether, it may not always be practical to do so.

Technology blog gHacks demonstrates how to fix the problem with a script that lets you take ownership quickly. Make sure to back up all important files before doing something like this.

After installing the script, users should right-click and take ownership of C:\Windows\diagnostics\scheduled\Maintenance\TS_BrokenShortcuts.ps1. After that, the user must run Command Prompt:

Open an elevated command line prompt. You do that by clicking on the Start orb, All Programs, then Accessories. Right-click the Command Prompt link and select to Run As Administrator.

Now issue the following command to grant the active user full rights of the file. Make sure you replace USERNAME with the name of the active user.

As always, proceed at your own risk when tackling these sorts of low-level system tweaks, but if this is an annoyance you've been dealing with, it might be worth a try. In addition, a similar procedure can prevent Windows from cleaning up unused desktop shortcuts, but after this tweak Windows should no longer delete these "broken" shortcuts.