0

If I change a file's location, its shortcut path is not updated until I double click on the shortcut. I want it to be updated on demand for bulk files in a path (reason: I move the files and folders to another computer and then by double-clicking on the shortcuts, they cannot be updated, so they don't work).

I found that shortcut updating is done by distributed link tracking, but don't know how to fix it.

My OS: Windows 10

4
  • First you say the shortucts update themselves when accessed, then you say they don't. Can you clarify? It's easy enough to modify shortcuts via scripting, but not without example paths for shortcuts & targets. Please edit your question to supply more detail. Feb 20, 2020 at 22:20
  • @KeithMiller I want to update them in bulk. Feb 22, 2020 at 8:47
  • I get that, but with what information??? How can we update the Target without knowing where the files have been moved to? Will it always be the same set of Shortcut/Target pairs? Are all the shortcuts in the same folder?, etc. Feb 22, 2020 at 9:17
  • @KeithMiller not all targets are the same, but Windows knows all the targets. When we double click each shortcut, the targets get fixed automatically by Windows, but we can't click on 100 shorctuts every week manually. They are in the same folder, but in various subfolders. Feb 22, 2020 at 10:35

1 Answer 1

1

I found that viewing the Properties of a shortcut & selecting Open File Location also updates the Target location. So, short of finding the right APIs & some serious programming, We're stuck with resorting to SendKeys(). After the SendKeys() sequence, if the folder with the shortcut was open for viewing prior to execution, if you right-click the shortcut & view its Properties, the Target appears unchanged. But this seems to be cached data. If you open a "fresh copy" of the folder, the shortcut's Target is updated. Edit as necessary & save a .ps1 file:

$wshShell = New-Object -ComObject wscript.shell
$Shell    = New-Object -ComObject shell.application

$LnkLocationParent = 'c:\path\to\FolderWithLnkFiles\'

$Shortcuts = gci $LnkLocationParent *.lnk -Recurse

$Shortcuts | ForEach{
    $oFolder = $shell.Namespace($_.DirectoryName)
    $oItem = $oFolder.ParseName($_.Name)
    $oitem.Verbs() | ?{$_.Name -like "P&roperties"} | %{$_.DoIt()}
    Start-Sleep 1
    $wshShell.SendKeys("%F")
    Start-Sleep 1
    $wshShell.SendKeys("%{F4}")
    Start-Sleep 1
    $wshShell.SendKeys("{Enter}")
    Start-Sleep 1
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .