I have an application auto updater which checks for new updates, moves the existing files including the app.exe into a new folder and copies the new version .exe + .dll's into the app folder
everything has been working perfectly without issues but there's one small glitch - the shortcuts created at the time of the original install become invalid
Is there a way to programmatically fix those shortcuts ?
You can update a shortcut using WshShell object (to identify folders and locations), and the Scripting.FilesystemObject to make the changes.
Here is an article on MSDN about the WshShell Object: http://msdn.microsoft.com/en-us/library/aew9yb99(VS.85).aspx
This is an example of replacing a shortcut link in VB Script:
Sub ReplaceShortcut (folder, target, targetTarget)
set oFso = CreateObject("Scripting.FilesystemObject")
Set oFolder = oFso.GetFolder(folder)
Set oFiles = oFolder.Files
For Each oFile In oFiles
If LCase(oFso.GetExtensionName(oFile.name)) = "lnk" Then
Set oLnk = oShell.CreateShortcut(oFile.path)
If instr(1, oLnk.TargetPath, target, 1)<>0 Then
oLnk.TargetPath = replace(oLnk.TargetPath, target, targetTarget)
oLnk.Save
End If
End If
Next
End Sub