From: Chris Morris Date: 2004-08-04T10:25:52+09:00 Subject: Re: Windows Shortcuts Mehr, Assaph (Assaph) wrote: >Hi All, > >Does anyone know how to programmatically create windows shortcuts (.lnk >files) using Ruby? >Have been googling for a couple of days without much luck. > > This is a method that depends on the Windows Scripting Host being installed, which it is by default on 2k and XP, I believe ... possibly others, but I don't know for sure. def create_shortcut(targetFileName, linkName) shell = WIN32OLE.new("WScript.Shell") scut = shell.CreateShortcut(linkName + '.lnk') scut.TargetPath = File.expand_path(targetFileName) scut.Save scut end The method returns the scut instance because there are other things you can do with it that this default method glosses over. This method is apart of my anemic clUtil lib (BSD license) you can get here: http://www.clabs.org/dl/clutil/ (see also http://www.clabs.org/ruby.htm). -- Chris http://clabs.org/blogki