Issue: Desktop shortcuts keep getting deleted (Windows 7)

Categories: Windows
Comments: No Comments
Published on: 2011/10/14

Issue:
There is a scheduled task in Windows 7 that runs every Sunday at 1:00 AM which includes, among other maintenance tasks, the deletion of shortcuts that have not been used for more than 60 days. This task also deletes what Microsoft calls “broken shortcuts”. These are shortcuts that point to locations or files that are no longer available on local drives or the network. The problem is that it always assumes shortcuts pointing to the network are not valid when they are pointing to a mapped drive, even when they are valid, and deletes them if there are more than 4. Basically the task is not aware of mapped drives even if the user is logged on, just UNC.

Resolution:

  1. Copy the code below to notepad and save it as resolve_deleted_shortcuts.bat
  2. Right click the script and run as administrator. Enter Administrator password if prompted
  3. Done
@echo off

REM **Script to resolve unused and broken shortcuts deletion issue**
REM **Rules out WinXP and other OS's***
If Not Exist "%SystemRoot%\diagnostics\scheduled\Maintenance" goto RESOLVED
REM **Start processing**
takeown /a /f "%SystemRoot%\diagnostics\scheduled\Maintenance\TS_UnusedDesktopIcons.ps1"
takeown /a /f "%SystemRoot%\diagnostics\scheduled\Maintenance\TS_BrokenShortcuts.ps1"
takeown /a /f "%SystemRoot%\diagnostics\scheduled\Maintenance\RS_RemoveShortcuts.ps1"
takeown /a /f "%SystemRoot%\diagnostics\scheduled\Maintenance\RS_RemoveUnusedDesktopIcons.ps1"
icacls "%SystemRoot%\diagnostics\scheduled\Maintenance\TS_UnusedDesktopIcons.ps1" /c /grant *S-1-5-32-544:f
icacls "%SystemRoot%\diagnostics\scheduled\Maintenance\TS_BrokenShortcuts.ps1" /c /grant *S-1-5-32-544:f
icacls "%SystemRoot%\diagnostics\scheduled\Maintenance\RS_RemoveShortcuts.ps1" /c /grant *S-1-5-32-544:f
icacls "%SystemRoot%\diagnostics\scheduled\Maintenance\RS_RemoveUnusedDesktopIcons.ps1" /c /grant *S-1-5-32-544:f
md c:\windows\diagnostics_bkp
move "%SystemRoot%\diagnostics\scheduled\Maintenance\TS_UnusedDesktopIcons.ps1" c:\windows\diagnostics_bkp\
move "%SystemRoot%\diagnostics\scheduled\Maintenance\TS_BrokenShortcuts.ps1" c:\windows\diagnostics_bkp\
move "%SystemRoot%\diagnostics\scheduled\Maintenance\RS_RemoveShortcuts.ps1" c:\windows\diagnostics_bkp\
move "%SystemRoot%\diagnostics\scheduled\Maintenance\RS_RemoveUnusedDesktopIcons.ps1" c:\windows\diagnostics_bkp\
:RESOLVED
No Comments - Leave a comment

Leave a comment

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*


Welcome , today is Saturday, 2017/12/16