Looking for: Dead Shortcut/Link (.LNK) Finder


  1. Posts : 52
    Microsoft Windows 10 Pro Education N 10.0.19044.2130
       #1

    Looking for: Dead Shortcut/Link (.LNK) Finder


    Does anyone know of an app/script to:
    1. scan whole folder/drive
    2. find all files ending in .lnk (i.e. shortcuts)
    3. if the thing that it's pointing to does not exist -> alert me / flag it / delete it / etc

    I'll continue searching online, but I must not be using the right keywords or it's hard to find.
      My Computer


  2. Posts : 5,478
    2004
       #2

    You could copy/paste this into powershell. It will make a file MissingTargets.txt on your desktop containing shortcuts where the target doesn't exist. Just need to change the drive letter D:\ in the first line.
    Code:
    $Shortcuts = Get-ChildItem -Recurse "D:\" -Include *.lnk
    
    $Shell = New-Object -ComObject WScript.Shell
    foreach ($Shortcut in $Shortcuts)
    {
    	$Properties = @{
    	ShortcutName = $Shortcut.Name
    	Path = $Shortcut.FullName
    	ShortcutDirectory = $Shortcut.DirectoryName
    	Target = $Shell.CreateShortcut($Shortcut).targetpath
    	}
    	New-Object PSObject -Property $Properties
    
    	if (-not (Test-Path $Properties.Target)) {$Properties.Path>>$env:homeDrive$env:homePath\Desktop\MissingTargets.txt} 
    }
    If you wanted to delete them instead of reporting them then change the line at the end from
    Code:
    if (-not (Test-Path $Properties.Target)) {$Properties.Path>>$env:homeDrive$env:homePath\Desktop\MissingTargets.txt}
    to
    Code:
    if (-not (Test-Path $Properties.Target)) {Remove-Item $Properties.Path -Force -ErrorAction 0}
    Based on this code [Powershell] Get Shortcut Target : AskGreg
      My Computer


  3. Posts : 42,963
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #3

    This is pretty good:
    Fix Shortcuts - Scan and Fix broken shorcuts on you computer
    That states Win 10 compatible. Freeware for personal use.
    http://www.puransoftware.com/screens...xShortcuts.jpg
    Looking for: Dead Shortcut/Link (.LNK) Finder-fixshortcuts.jpg
    ===========================================
    Older tool here:
    Search, Identify And Resolve Broken Shortcuts
    (not tried)

    (Searched for "detect scan for dead shortcuts")
    Attached Thumbnails Attached Thumbnails Looking for: Dead Shortcut/Link (.LNK) Finder-snap-2017-03-22-08.05.49.jpg  
    Last edited by dalchina; 22 Mar 2017 at 03:32.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 22:07.
Find Us




Windows 10 Forums