Shortcut Resource
Synopsis
Manages Windows shortcut (.lnk) files using COM interop with the Windows Shell.
Type
Capabilities
- Get
- Set
- Delete
Properties
path
The full path to the .lnk file.
targetPath
The target path the shortcut points to.
arguments
Command-line arguments for the target.
workingDirectory
The working directory for the target.
description
A description for the shortcut.
iconLocation
The icon file path and index.
hotkey
The hotkey combination for the shortcut.
windowStyle
Window style. Accepts Normal, Minimized, or Maximized.
_exist
Whether the shortcut should exist.
Examples
Example 1 — Create a desktop shortcut
Example 2 — Configuration document
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Notepad shortcut on desktop
type: OpenDsc.Windows/Shortcut
properties:
path: C:\Users\Public\Desktop\Notepad.lnk
targetPath: C:\Windows\notepad.exe
description: Open Notepad
Exit codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Invalid JSON |
| 3 | Failed to generate schema |
| 4 | Directory not found |