Matthew van Eerde's web log
I am a Software Development Engineer in Test working for the Windows Sound team. You can contact me via email: mateer at microsoft dot com
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" WScript.QuitEnd If 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)End If link.Save
>cscript create-shortcut.vbs "%appdata%\Microsoft\Windows\SendTo\Notepad.lnk" notepad.exe