1

Is there a way to use PowerShell to manage Explorer's shortcut?

For example, remove 7346 then add a link to ~/Projects/9999?

enter image description here

craig
  • 25,664
  • 27
  • 119
  • 205

1 Answers1

5

Favourites in Explorer are shortcuts in \Links folder in your profile. So if you want to remove 7346:

rm $home\Links\7346.lnk

Creating one is rather cumbersome in PS:

$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Home\Links\9999.lnk")
$Shortcut.TargetPath = "$home\9999"
$Shortcut.Save()

Adjust target path if 9999 doesn't sit in the root of your user profile.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Raf
  • 9,681
  • 1
  • 29
  • 41
  • 1
    You should probably use `$env:USERPROFILE` instead of `$Home` (in case AD profile path points to a network share) – Mathias R. Jessen Apr 29 '15 at 16:46
  • 1
    [This question](https://stackoverflow.com/questions/9701840/how-to-create-a-shortcut-using-powershell) had a similar answer. – craig Apr 29 '15 at 16:46