TestPartner: Automating the creation of a Desktop Shortcut

TestPartner: Automating the creation of a Desktop Shortcut

The basic approach to creating a desktop shortcut for a program in a Script or Visual Test is to automate a right-click against the executable in Windows Explorer before selecting 'Send to > Desktop (create shortcut)' from the context menu. This type of approach generally works well but will fail on on Windows 8.1(32 bit) because the right-click context menu will not be recognized.

As an alternative to automating Windows Explorer you can instead use Shell's COM API to create the desktop shortcut as shown in the following function:

The CreateShortcut function accepts 2 parameters: the path to the executable and the name that you want to assign the shortcut once it's created on the desktop.

You can download a TestPartner Asset containing the code via the following link:



Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Version history
Revision #:
1 of 1
Last update:
‎2014-10-13 16:17
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.