Working on Windows, I install Windows a lot. This means a lot of my customizations have to be re-applied every time I install. To save myself some time I created a script which applies some of them. Last time I showed how to set the desktop wallpaper from a command-line app.
This time, a script to create a shortcut. The example usage creates a shortcut to Notepad and puts that in the "SendTo" folder. I find this very useful because I often need to edit text files that have non-".txt" assocations. (There are also other shortcuts I create with it.)
Here's the script:
If WScript.Arguments.Count < 2 Or WScript.Arguments.Count > 3 Then
WScript.Echo "Expected two or three arguments; got " & WScript.Arguments.Count
WScript.Echo "First argument is the file to create"
WScript.Echo "Second is the command to link to"
WScript.Echo "Third, if present, is the arguments to pass"
Set shell = WScript.CreateObject("WScript.Shell")
Set link = shell.CreateShortcut(WScript.Arguments(0))
link.TargetPath = WScript.Arguments(1)
If WScript.Arguments.Count = 3 Then
link.Arguments = WScript.Arguments(2)
>cscript create-shortcut.vbs "%appdata%\Microsoft\Windows\SendTo\Notepad.lnk" notepad.exe
EDIT 2015-10-31: added script to https://github.com/mvaneerde/blog/blob/master/scripts/create-shortcut.vbs