Created
May 3, 2021 04:41
-
-
Save vvuk/0758fc034a794bf56c1e985edcd59c88 to your computer and use it in GitHub Desktop.
Clean up stale start menu links, such as after Windows Recovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$shell = New-Object -COM WScript.Shell | |
$basedir = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\" | |
Get-ChildItem -Path $basedir -Filter *.lnk -Recurse -File -Name | ForEach-Object { | |
$rpath = $basedir+$_ | |
## Write-Output $rpath | |
$cut = $shell.CreateShortcut($rpath) | |
If (($cut.TargetPath -eq "") -Or (-Not (Test-Path $cut.TargetPath))) { | |
Write-Output $_ | |
Remove-Item $rpath | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment