PSAdvancedShortcut is a tool to allow the creation of shortcut files on Windows machines. Its purpose is to make the powerful hidden properties of shortcuts easy to set, in a programmatic way.
Some of the properties that can be set include:
- Target
- Arguments
- Working directory
- Description
- Window launch style
- Icon (including index offset)
- Application user model ID (AUMID)
- Toast activator class ID
You can install PSAdvancedShortcut via the Powershell Gallery:
Install-Module -Name PSAdvancedShortcut
Creates a new shortcut with the desired properties.
New-Shortcut
-Name <string>
-Target <string>
[-Arguments <string>]
[-Path <string>]
[-Description <string>]
[-WorkingDirectory <string>]
[-WindowStyle <WindowStyle>]
[-IconPath <string>]
[-IconIndex <int>]
[-AppUserModelId <string>]
[-ToastActivatorClassId <Guid>]
[-Force]
[<CommonParameters>]
Create a simple shortcut named MyShortcut
in the current directory, targeting the calculator:
New-Shortcut -Name MyShortcut -Target calc.exe
Creates a shortcut on the desktop called MyDesktopShortcut
, targeting the calculator:
New-Shortcut -Name MyDesktopShortcut -Path ~\Desktop -Target calc.exe
Creates a shortcut in the current directory named TreeCalc
with a tree icon, targeting the calculator:
New-Shortcut -Name TreeCalc -Target calc.exe -IconPath C:\Windows\System32\SHELL32.dll -IconIndex 41
The name of the shortcut. Will automatically append .lnk
if not included - but note that the file extension is always hidden by the OS. If a shortcut by this name already exists in the directory, you must specify -Force
to replace it.
The executable or shell destination of the shortcut.
Arguments to pass into the target.
The directory to create the shortcut under. The directory must exist and be writable.
A string that describes the shortcut. This will be displayed when the user hovers over the shortcut icon.
Specifies the directory that the target should be launched under.
The style of the window that the target should open in. The acceptable values are Normal
, Maximized
, and Minimized
. Note that this does not work for all applications.
The full path to a file which contains an icon. This is usually a .ico file, but may also include .icl, .exe, and .dll files.
Icon files, as well as binaries, may contain multiple icons. You can specify the offset with this parameter. The index starts at zero.
The AUMID to set for this shortcut. The format typically follows Java's package name rules, but can be any string. This only applies to Windows 8 and above.
Specifies the GUID for the registered COM class which will be activated when a user clicks on a notification in the Action Center from your application. This only applies to Windows 8 and above.
Specifies that an existing shortcut should be overwritten.
None
None
Finds a shortcut that links to the specified target, within a specified directory.
NOTE: This cmdlet does not currently work on Windows 7
Find-Shortcut
-Target <string>
[-Path <string>]
[-Recurse]
[<CommonParameters>]
Find the shortcut files which target the calculator:
Find-Shortcut -Target C:\Windows\System32\calc.exe
The absolute path of the target you wish to find shortcuts for.
Note that if you created a shortcut with a non-absolute path to a target, the OS will fill-in the rest of the path to become absolute at creation time. You will not, for example, be able to find any shortcuts which target calc.exe
.
The directory which should be searched to find shortcuts. Defaults to the current directory. The directory must exist.
Recursively search into subdirectories, including network drives and symbolic links.
string
A string representing the full path to the target may be supplied from the pipeline, instead of using the parameter -Target
.
string[]
String array of absolute file paths of the shortcuts which match the target specified.