Create Desktop or Start Menu Shortcuts

Problem

You want to add a new shortcut to the desktop or the Start menu.

Solution

Use COM Interop to access the Windows Script Host component, which provides a WshShell.CreateShortcut method.

Discussion

There are several approaches that you can take if you want to programmatically create a shortcut file. You can use an unmanaged call to a legacy API (such as the Visual Basic 6 setup toolkit DLL), create the file by hand (in which case you need an in-depth understanding of its proprietary format), or create a dedicated Windows Installer setup program. The easiest approach is to use the Windows Script Host component, which is included with the Windows operating system. You can interact with this COM component through ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.