Skip to content

Instantly share code, notes, and snippets.

@JTRNS
Created June 14, 2021 06:49
Show Gist options
  • Save JTRNS/71f022e02795f15a6fc3bb4ac167154a to your computer and use it in GitHub Desktop.
Save JTRNS/71f022e02795f15a6fc3bb4ac167154a to your computer and use it in GitHub Desktop.
Copy all links from start menu subdirectories into start menu programs directory
# Windows uses some of the .lnk files in the start menu to launch system utilities. So copy,
# but do not move / remove links like Powershell.
# system and user start menu directories
$SystemStartMenuDir = "$env:ProgramData\Microsoft\Windows\Start Menu\Programs"
$UserStartMenuDir = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs"
# copy links (.lnk files) from system start menu directory to user start menu directory
Get-ChildItem -Path $SystemStartMenuDir -File -Include "*.lnk" -Recurse | Copy-Item -Destination $UserStartMenuDir
# remove all non-links (readme's, manuals, urls etc.) from the system start menu
Get-ChildItem -Path $SystemStartMenuDir -File -Exclude "*.lnk" -Recurse | Remove-Item -Confirm
# copy all links from subdirectories in user start menu to the programs directory
Get-ChildItem -Path "$UserStartMenuDir\*" -Directory | Get-ChildItem -File -Include "*.lnk" | Copy-Item -Destination $UserStartMenuDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment