Skip to content

Instantly share code, notes, and snippets.

@MyITGuy
Created June 4, 2014 22:03
Show Gist options
  • Save MyITGuy/f012ed448d90781c6670 to your computer and use it in GitHub Desktop.
Save MyITGuy/f012ed448d90781c6670 to your computer and use it in GitHub Desktop.
PowerShell: Create Send To shortcut in the Send To folder.
$sendToPath = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\SendTo"
$shortcutPath = "$sendToPath\SendTo.lnk"
try {
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($shortcutPath)
$Shortcut.TargetPath = "$($sendToPath)"
$Shortcut.Description = "Send shortcut to this folder"
$Shortcut.Save()
"Shortcut created successfully"
return
} catch {
"Failed to create shortcut"
return
} finally {
# Cleanup
Remove-Variable sendToPath -ErrorAction SilentlyContinue
Remove-Variable shortcutPath -ErrorAction SilentlyContinue
Remove-Variable Shortcut -ErrorAction SilentlyContinue
Remove-Variable WshShell -ErrorAction SilentlyContinue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment