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
}