Last active
January 13, 2023 21:18
-
-
Save tankerkiller125/54bc00831cfb699a97ddebcec738dd2b to your computer and use it in GitHub Desktop.
Windows Shortcut Repair
This file contains 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
# Set the Start Menu Path | |
$StartMenuFolder = "$env:ProgramData\Microsoft\Windows\Start Menu\Programs" | |
# Define the website to pull the JSON from | |
$URL = Invoke-WebRequest 'https://internal.corp/shortcuts.json' -UseBasicParsing | |
$ShortCuts = $URL | ConvertFrom-Json | |
# Use this instead if you don't want to use a website path | |
#$ShortCuts = Get-Content -Path .\shortcuts.json | ConvertFrom-Json | |
# Loop through the JSON | |
foreach ($shortcut in $ShortCuts) { | |
# Check to see if the application actually exists on the PC | |
if (Test-Path $shortcut.Path) { | |
# Create the shortcut folder if it doesn't already exist | |
New-Item "$StartMenuFolder\$($shortcut.StartMenuPath)" -ItemType Directory -Force | |
# Create the shortcut using the specified information | |
$WshShell = New-Object -ComObject WScript.Shell | |
$Scut = $WshShell.CreateShortcut("$StartMenuFolder\$($shortcut.StartMenuPath)\$($shortcut.LinkName)") | |
$Scut.TargetPath = $shortcut.Path | |
$Scut.Arguments = $shortcut.Arguments | |
$Scut.Save() | |
} | |
} |
This file contains 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
[ | |
{ | |
"StartMenuPath": "Microsoft Office", | |
"LinkName": "Word.lnk", | |
"Path": "C:\\Program Files\\Microsoft Office\\root\\Office16\\WINWORD.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "Microsoft Office", | |
"LinkName": "Excel.lnk", | |
"Path": "C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "Microsoft Office", | |
"LinkName": "Outlook.lnk", | |
"Path": "C:\\Program Files\\Microsoft Office\\root\\Office16\\OUTLOOK.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartmenuPath": "Microsoft Office", | |
"LinkName": "PowerPoint.lnk", | |
"Path": "C:\\Program Files\\Microsoft Office\\root\\Office16\\POWERPNT.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "Microsoft Office", | |
"LinkName": "Access.lnk", | |
"Path": "C:\\Program Files\\Microsoft Office\\root\\Office16\\MSACCESS.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "Microsoft Office", | |
"LinkName": "Publisher.lnk", | |
"Path": "C:\\Program Files\\Microsoft Office\\root\\Office16\\MSPUB.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "Microsoft Office", | |
"LinkName": "OneNote.lnk", | |
"Path": "C:\\Program Files\\Microsoft Office\\root\\Office16\\ONENOTE.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "", | |
"LinkName": "Remote Desktop.lnk", | |
"Path": "C:\\Program Files\\Remote Desktop\\msrdcw.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "", | |
"LinkName": "Microsoft Edge.lnk", | |
"Path": "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "Google", | |
"LinkName": "Google Chrome.lnk", | |
"Path": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", | |
"Arguments": "" | |
}, | |
{ | |
"StartMenuPath": "", | |
"LinkName": "Windows Sandbox.lnk", | |
"Path": "%windir%\\system32\\WindowsSandbox.exe", | |
"Arguments": "" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment