1#!/usr/local/bin/python3.8 2# -*- coding: utf-8 -*- 3 4# Copyright: (c) 2016, Dag Wieers (@dagwieers) <dag@wieers.com> 5# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 6 7DOCUMENTATION = r''' 8--- 9module: win_shortcut 10short_description: Manage shortcuts on Windows 11description: 12- Create, manage and delete Windows shortcuts 13options: 14 src: 15 description: 16 - Executable or URL the shortcut points to. 17 - The executable needs to be in your PATH, or has to be an absolute 18 path to the executable. 19 type: str 20 description: 21 description: 22 - Description for the shortcut. 23 - This is usually shown when hoovering the icon. 24 type: str 25 dest: 26 description: 27 - Destination file for the shortcuting file. 28 - File name should have a C(.lnk) or C(.url) extension. 29 type: path 30 required: yes 31 arguments: 32 description: 33 - Additional arguments for the executable defined in C(src). 34 type: str 35 aliases: [ args ] 36 directory: 37 description: 38 - Working directory for executable defined in C(src). 39 type: path 40 icon: 41 description: 42 - Icon used for the shortcut. 43 - File name should have a C(.ico) extension. 44 - The file name is followed by a comma and the number in the library file (.dll) or use 0 for an image file. 45 type: path 46 hotkey: 47 description: 48 - Key combination for the shortcut. 49 - This is a combination of one or more modifiers and a key. 50 - Possible modifiers are Alt, Ctrl, Shift, Ext. 51 - Possible keys are [A-Z] and [0-9]. 52 type: str 53 windowstyle: 54 description: 55 - Influences how the application is displayed when it is launched. 56 type: str 57 choices: [ maximized, minimized, normal ] 58 state: 59 description: 60 - When C(absent), removes the shortcut if it exists. 61 - When C(present), creates or updates the shortcut. 62 type: str 63 choices: [ absent, present ] 64 default: present 65 run_as_admin: 66 description: 67 - When C(src) is an executable, this can control whether the shortcut will be opened as an administrator or not. 68 type: bool 69 default: no 70notes: 71- 'The following options can include Windows environment variables: C(dest), C(args), C(description), C(dest), C(directory), C(icon) C(src)' 72- 'Windows has two types of shortcuts: Application and URL shortcuts. URL shortcuts only consists of C(dest) and C(src)' 73seealso: 74- module: ansible.windows.win_file 75author: 76- Dag Wieers (@dagwieers) 77''' 78 79EXAMPLES = r''' 80- name: Create an application shortcut on the desktop 81 community.windows.win_shortcut: 82 src: C:\Program Files\Mozilla Firefox\Firefox.exe 83 dest: C:\Users\Public\Desktop\Mozilla Firefox.lnk 84 icon: C:\Program Files\Mozilla Firefox\Firefox.exe,0 85 86- name: Create the same shortcut using environment variables 87 community.windows.win_shortcut: 88 description: The Mozilla Firefox web browser 89 src: '%ProgramFiles%\Mozilla Firefox\Firefox.exe' 90 dest: '%Public%\Desktop\Mozilla Firefox.lnk' 91 icon: '%ProgramFiles\Mozilla Firefox\Firefox.exe,0' 92 directory: '%ProgramFiles%\Mozilla Firefox' 93 hotkey: Ctrl+Alt+F 94 95- name: Create an application shortcut for an executable in PATH to your desktop 96 community.windows.win_shortcut: 97 src: cmd.exe 98 dest: Desktop\Command prompt.lnk 99 100- name: Create an application shortcut for the Ansible website 101 community.windows.win_shortcut: 102 src: '%ProgramFiles%\Google\Chrome\Application\chrome.exe' 103 dest: '%UserProfile%\Desktop\Ansible website.lnk' 104 arguments: --new-window https://ansible.com/ 105 directory: '%ProgramFiles%\Google\Chrome\Application' 106 icon: '%ProgramFiles%\Google\Chrome\Application\chrome.exe,0' 107 hotkey: Ctrl+Alt+A 108 109- name: Create a URL shortcut for the Ansible website 110 community.windows.win_shortcut: 111 src: https://ansible.com/ 112 dest: '%Public%\Desktop\Ansible website.url' 113''' 114 115RETURN = r''' 116''' 117