Shortcuts can be handy.
They let us launch things at the click of a button.
This can be extra handy for people who are allergic to terminals.
Shortcut is a simple module to create shortcuts with scripts.
It can create:
- Windows shortcuts (
.lnkand.urlfiles) - Linux
.desktopshortcuts - HTML shortcuts
<a>
You can install Shortcut from the PowerShell gallery
Install-Module Shortcut -Scope CurrentUser -ForceOnce installed, you can import the module with:
Import-Module Shortcut -PassThruYou can also clone the repo and import the module locally:
git clone https://github.com/StartAutomating/Shortcut
cd ./Shortcut
Import-Module ./ -PassThruShortcut has 1 function
Simple Shortcuts with PowerShell
| Name | Type | Description |
|---|---|---|
| ShortcutFile | String | The name of the shortcut file. |
| Url | Uri | The shortcut url |
| PowerShell | PSObject | Any PowerShell to run. This must be either a ScriptBlock or a .ps1 path If it is a ScriptBlock, a file will be created in the same location as the link. |
| Content | Object[] | The content of a simple url shortcut. If only a -Url or a -Url and -Content and provided, will create an HTML shortcut <a href> |
| Description | String | A description of the shortcut. This is ignored for .url shortcut files. |
| TargetPath | String | The target path of the link. |
| HotKey | String | The hotkey. This is theoretically supported by the shortcut object but may be ignored by explorer. |
| IconLocation | String | The icon location The path containing an icon, followed by the index in that path. |
| WorkingDirectory | String | The working directory |
| WindowStyle | Int32 | The window style. |
| Fullscreen | SwitchParameter | If set, will make a fullscreen shortcut. Ignored for url shortcuts This is equivalent to using -WindowStyle 3 |
| Arguments | String[] | Any arguments to the application |
| ShowLogo | SwitchParameter | If set, will show the PowerShell logo This is ignored if -PowerShell is not passed |
| AutoExit | SwitchParameter | If set, will automatically exit upon completion This is ignored if -PowerShell is not passed. |
| DesktopEntry | IDictionary | Any Desktop Entry settings Settings provided by other parameters will be automatically mapped (where possible) |
Create a .url shortcut (Windows Only)
Shortcut ./psturtle.com.url "https://psturtle.com"Create a .lnk shortcut (Windows Only)
Shortcut ./pwsh.lnk -TargetPath pwshCreate a .lnk shortcut to PowerShell
Shortcut ./pwsh-fullscreen.lnk -TargetPath pwsh -FullscreenCreate a .lnk shortcut to a PowerShell script.
Shortcut ./pwsh-hello-world.lnk -PowerShell { "hello world" }Create a .desktop shortcut to a PowerShell script
Shortcut ./pwsh.desktop -TargetPath /usr/bin/pwsh