Created
June 4, 2014 22:03
-
-
Save MyITGuy/f012ed448d90781c6670 to your computer and use it in GitHub Desktop.
PowerShell: Create Send To shortcut in the Send To folder.
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
$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