2017-01-16 18:51:56 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2017-09-21 19:37:15 +00:00
|
|
|
# Copyright: (c) 2016, Dag Wieers (@dagwieers) <dag@wieers.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2017-01-16 18:51:56 +00:00
|
|
|
|
2017-08-16 03:16:38 +00:00
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
2017-03-14 16:07:22 +00:00
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'community'}
|
|
|
|
|
2017-09-21 19:37:15 +00:00
|
|
|
DOCUMENTATION = r'''
|
2017-01-16 18:51:56 +00:00
|
|
|
---
|
|
|
|
module: win_shortcut
|
|
|
|
version_added: '2.3'
|
|
|
|
short_description: Manage shortcuts on Windows
|
|
|
|
description:
|
|
|
|
- Create, manage and delete Windows shortcuts
|
|
|
|
options:
|
|
|
|
src:
|
|
|
|
description:
|
|
|
|
- Executable or URL the shortcut points to.
|
2017-07-18 20:32:06 +00:00
|
|
|
- The executable needs to be in your PATH, or has to be an absolute
|
|
|
|
path to the executable.
|
2017-01-16 18:51:56 +00:00
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Description for the shortcut.
|
|
|
|
- This is usually shown when hoovering the icon.
|
|
|
|
dest:
|
|
|
|
description:
|
|
|
|
- Destination file for the shortcuting file.
|
|
|
|
- File name should have a C(.lnk) or C(.url) extension.
|
2017-07-18 20:32:06 +00:00
|
|
|
required: yes
|
2017-01-16 18:51:56 +00:00
|
|
|
args:
|
|
|
|
description:
|
|
|
|
- Additional arguments for the executable defined in C(src).
|
|
|
|
directory:
|
|
|
|
description:
|
|
|
|
- Working directory for executable defined in C(src).
|
|
|
|
icon:
|
|
|
|
description:
|
2017-07-18 20:32:06 +00:00
|
|
|
- Icon used for the shortcut.
|
2017-01-16 18:51:56 +00:00
|
|
|
- File name should have a C(.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.
|
|
|
|
hotkey:
|
|
|
|
description:
|
|
|
|
- Key combination for the shortcut.
|
2017-09-21 19:37:15 +00:00
|
|
|
- This is a combination of one or more modifiers and a key.
|
|
|
|
- Possible modifiers are Alt, Ctrl, Shift, Ext.
|
|
|
|
- Possible keys are [A-Z] and [0-9].
|
2017-01-16 18:51:56 +00:00
|
|
|
windowstyle:
|
|
|
|
description:
|
|
|
|
- Influences how the application is displayed when it is launched.
|
2017-09-21 19:37:15 +00:00
|
|
|
choices: [ maximized, minimized, normal ]
|
2017-01-16 18:51:56 +00:00
|
|
|
state:
|
|
|
|
description:
|
2017-09-21 19:37:15 +00:00
|
|
|
- When C(present), creates or updates the shortcut.
|
|
|
|
- When C(absent), removes the shortcut if it exists.
|
|
|
|
choices: [ absent, present ]
|
2017-07-18 20:32:06 +00:00
|
|
|
default: present
|
|
|
|
author:
|
|
|
|
- Dag Wieers (@dagwieers)
|
2017-01-16 18:51:56 +00:00
|
|
|
notes:
|
|
|
|
- 'The following options can include Windows environment variables: C(dest), C(args), C(description), C(dest), C(directory), C(icon) C(src)'
|
|
|
|
- 'Windows has two types of shortcuts: Application and URL shortcuts. URL shortcuts only consists of C(dest) and C(src)'
|
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = r'''
|
2017-07-18 20:32:06 +00:00
|
|
|
- name: Create an application shortcut on the desktop
|
|
|
|
win_shortcut:
|
2017-01-16 18:51:56 +00:00
|
|
|
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
|
|
|
|
|
2017-07-18 20:32:06 +00:00
|
|
|
- name: Create the same shortcut using environment variables
|
|
|
|
win_shortcut:
|
2017-01-16 18:51:56 +00:00
|
|
|
description: The Mozilla Firefox web browser
|
2017-07-18 20:32:06 +00:00
|
|
|
src: '%ProgramFiles%\Mozilla Firefox\Firefox.exe'
|
|
|
|
dest: '%Public%\Desktop\Mozilla Firefox.lnk'
|
|
|
|
icon: '%ProgramFiles\Mozilla Firefox\Firefox.exe,0'
|
|
|
|
directory: '%ProgramFiles%\Mozilla Firefox'
|
2017-09-21 19:37:15 +00:00
|
|
|
hotkey: Ctrl+Alt+F
|
2017-07-18 20:32:06 +00:00
|
|
|
|
|
|
|
- name: Create an application shortcut for an executable in PATH to your desktop
|
|
|
|
win_shortcut:
|
|
|
|
src: cmd.exe
|
|
|
|
dest: Desktop\Command prompt.lnk
|
2017-01-16 18:51:56 +00:00
|
|
|
|
2017-07-18 20:32:06 +00:00
|
|
|
- name: Create an application shortcut for the Ansible website
|
|
|
|
win_shortcut:
|
|
|
|
src: '%ProgramFiles%\Google\Chrome\Application\chrome.exe'
|
|
|
|
dest: '%UserProfile%\Desktop\Ansible website.lnk'
|
|
|
|
args: --new-window https://ansible.com/
|
|
|
|
directory: '%ProgramFiles%\Google\Chrome\Application'
|
|
|
|
icon: '%ProgramFiles%\Google\Chrome\Application\chrome.exe,0'
|
2017-09-21 19:37:15 +00:00
|
|
|
hotkey: Ctrl+Alt+A
|
2017-01-16 18:51:56 +00:00
|
|
|
|
2017-07-18 20:32:06 +00:00
|
|
|
- name: Create a URL shortcut for the Ansible website
|
|
|
|
win_shortcut:
|
|
|
|
src: https://ansible.com/
|
|
|
|
dest: '%Public%\Desktop\Ansible website.url'
|
2017-01-16 18:51:56 +00:00
|
|
|
'''
|
|
|
|
|
2017-09-21 19:37:15 +00:00
|
|
|
RETURN = r'''
|
2017-01-27 21:04:59 +00:00
|
|
|
'''
|