AHK offers two commands to work with shortcut files (.lnk).
FileSetShortcut and FileGetShortcut
I would like to modify the target of an existing shortcut file.
What can be done to modify an existing shortcut file?
Of cause I could delete the old and create a new one.
But is there a way to modify an existing shortcut file?
PS: I am planing to write a short script that searches for broken shortcuts (e.g. due to moving or deleting files) on a server and offers to correct the target or to delete the shortcut, similar to the shareware program Shortcut Doctor. If you have any hint on such a script or other program that does such a task, please post as well. Thanks a lot in advance.
Modify shortcut file
Modify shortcut file
ciao
toralf
toralf
Re: Modify shortcut file
The easiest way is probably using the Windows Scripting Host COM interface:
Otherwise, using the IShellLink(A/W) interface, like FileCreateShortcut does, is an option.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; https://msdn.microsoft.com/en-us/library/xsy6k3ys(v=vs.84).aspx
; https://msdn.microsoft.com/en-us/library/xk6kst2k(v=vs.84).aspx
wsh := ComObjCreate("WScript.Shell")
lnk := wsh.CreateShortcut("<path to existing lnk file or one to create>")
lnk.TargetPath := "D:\"
lnk.Save()
Re: Modify shortcut file
for later reference
https://autohotkey.com/boards/viewtopic ... 261#p25261
https://autohotkey.com/boards/viewtopic ... 261#p25261
ciao
toralf
toralf