Documentation

win_shortcut - Manage shortcuts on Windows

New in version 2.3.

Synopsis

  • Create, manage and delete Windows shortcuts

Options

parameter required default choices comments
args
no
Additional arguments for the executable defined in src.
description
no
Description for the shortcut.
This is usually shown when hoovering the icon.
dest
yes
Destination file for the shortcuting file.
File name should have a .lnk or .url extension.
directory
no
Working directory for executable defined in src.
hotkey
no
Key combination for the shortcut.
icon
no
Icon used for the shortcut
File name should have a .ico extension.
The file name is followed by a comma and the number in the library file (.dll) or use 0 for an image file.
src
no
Executable or URL the shortcut points to.
state
no present
  • present
  • absent
When present, creates or updates the shortcut. When absent, removes the shortcut if it exists.
windowstyle
no
  • default
  • maximized
  • minimized
Influences how the application is displayed when it is launched.

Examples

# Create an application shortcut on the desktop
- win_shortcut:
    src: C:\Program Files\Mozilla Firefox\Firefox.exe
    dest: C:\Users\Public\Desktop\Mozilla Firefox.lnk
    icon: C:\Program Files\Mozilla Firefox\Firefox.exe,0

# Create the same shortcut using environment variables
- win_shortcut:
    description: The Mozilla Firefox web browser
    src: '%PROGRAMFILES%\Mozilla Firefox\Firefox.exe'
    dest: '%PUBLIC%\Desktop\Mozilla Firefox.lnk'
    icon: '%PROGRAMFILES\Mozilla Firefox\Firefox.exe,0'
    directory: '%PROGRAMFILES%\Mozilla Firefox'

# Create a URL shortcut to the Ansible website
- win_shortcut:
    src: 'https://ansible.com/'
    dest: '%PUBLIC%\Desktop\Ansible website.url'

# Create an application shortcut for the Ansible website
- win_shortcut:
    src: '%PROGRAMFILES%\Google\Chrome\Application\chrome.exe'
    dest: '%PUBLIC%\Desktop\Ansible website.lnk'
    args: '--new-window https://ansible.com/'
    directory: '%PROGRAMFILES%\Google\Chrome\Application'
    icon: '%PROGRAMFILES%\Google\Chrome\Application\chrome.exe,0'

Notes

Note

  • The following options can include Windows environment variables: dest, args, description, dest, directory, icon src
  • Windows has two types of shortcuts: Application and URL shortcuts. URL shortcuts only consists of dest and src

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Support

This module is community maintained without core committer oversight.

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.