PDA

View Full Version : Creating .ink shortcuts



pcsyoga
2004-06-17, 02:10 PM
Is there a way to create a .ink shortcut with lisp? I am copying network files to a hard drive, and would like to create a shortcut to the network directory programmatically, so it would be easy to save back to the network.

stig.madsen
2004-06-17, 03:21 PM
Thought I could find one in McNeels DosLib library but no luck. Maybe someone here knows the answer to that.

Otherwise, you can utilize the Shell scripting object. The following function creates a shortcut based on these arguments:

target: path of file to make a shortcut to
fname: filebase name of shortcut file (without extension)
path: where to put the shortcut



(defun myShortcut (target fname path / shellObj shortcut)
(cond ((setq shellObj (vlax-create-object "WScript.Shell"))
(setq shortcut (vlax-invoke-method
shellObj
'CreateShortcut
(strcat path "\\" fname ".lnk")
)
)
(vlax-put-property shortcut 'TargetPath target)
(vlax-invoke-method shortcut 'Save)
(vlax-release-object shortcut)
(vlax-release-object shellObj)
)
)
)

Of course, you'd probably want some user interface to go with it but it should be basic stuff.

pcsyoga
2004-06-17, 05:30 PM
Awesome Stig!
Thanks for all your help.