Generating shortcuts for Launchy

17. September 2011 22:47

If you have read my previous post on Launchy, you know I prefer Launchy as a means to start programs using the keyboard only using the Windows start menu, either by mouse or by entering a search string. By default, Launchy indexes your start menu, but you can easily add other locations by going to the options screen. On the catalog tab, you can add as many search locations as you like. If you want, you can even have Launchy index your document folders to quickly open your documents.

However, setting up Launchy on each new computer can get a bit tedious, especially if you start adding custom shortcuts, like preferred bookmarks or other shortcuts that are a bit more elaborate/specific than what you would find in your start menu. So, I have written a little script that generates the necessary shortcuts in a folder of my choosing. On a new computer, all I have to do is run the generate script, add a folder to the Launchy catalog, and re-index the catalog.

 

The generate script

To generate .lnk (shortcut) files, I use xxmklink.exe. You could also use shortcut.exe (from the Windows development toolkit), but xxmklink has a few more options. There are a couple of folders in play here, most of which are synced between computers using Windows Live Mesh, part of Windows Live Essentials. There are:

  • folder_scriptroot: this is where all the scripts that are used are located
  • folder_scriptresources: home of all the resources that are used by scripts (among which is xxmklink.exe, but it also houses template files and any other file your script might depend upon
  • folder_launchylinks: location where the Launchy shortcuts will be created

The generate script (a batch file) uses the %COMPUTER_NAME% environment variable to set different values for these variables. You can see an example of this in the demo script at the end of this post.

 

Useful links

A couple of suggestions for the links you can add to your generate script:

  • Remote desktop connections to various machines you want to connect to (sample in the demo script)
  • Shortcuts to specific batch files (or other scripts) you use
  • Links to locations on your machine or network (possibly extended with Windows Explorer command line switches)
  • Links to autohotkey files

And the list goes on. I have about 15-25 links generated this way, depending on the machine.

 

Demo script

A short demo script looks like this:

 

@echo off

setlocal

if %COMPUTERNAME%==CARRIE goto laptop
if %COMPUTERNAME%==TOUCHY goto tablet

echo Computer %COMPUTERNAME% not found!
goto end

:laptop
set folder_skydrive=C:\Users\tijmenvdk\_SkyDrive\
set folder_launchylinks=C:\Users\tijmenvdk\Programs\Launchy\
goto continue

:tablet
set folder_skydrive=C:\Users\me\_SkyDrive\
set folder_launchylinks=c:\users\me\programs\Launchy\
goto continue

:continue
set folder_scriptroot=%folder_skydrive%scripts\prod\
set folder_scriptresources=%folder_scriptroot%resources\
set app_makelink=%folder_scriptresources%xxmklink.exe


"%app_makelink%" /q "%folder_launchylinks%dolores remote desktop.lnk"  "%windir%\system32\mstsc.exe" "/v:dolores /admin /w:1024 /h:768" "" "" "1"
"%app_makelink%" /q "%folder_launchylinks%newmessage.lnk"              "C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE" "/c ipm.note" "" "" "7"

:end
endlocal
pause
Comments are closed