> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/rdm/knowledge-base/knowledge-base-articles/entry-settings/common-settings/events.md).

# Events

Run scripts, commands, messages, macros or clipboard actions before and after a session opens or closes, in the Events section of Remote Desktop Manager.

The ***Events*** section runs an action at four moments of a session: before it opens, after it opens, before it closes and after it closes. It also powers on the host with Wake-on-LAN, sends port knocks and types a macro after the session opens. For an overview, see [Events](https://docs.devolutions.net/rdm/concepts/advanced-concepts/events.md).

Available for session entries. In the entry properties, select ***Connection*** – ***Events***. By default, the section is hidden in the simplified view of the properties; select ***Show all properties*** to display it.

With [batch edit](https://docs.devolutions.net/rdm/ribbon-menu-bar/edit/batch-edit.md), select ***Override*** to replace these settings on every selected entry. Whether events can run in a vault depends on the ***Session events*** setting of the vault, in [Security settings](https://docs.devolutions.net/rdm/knowledge-base/knowledge-base-articles/entry-settings/common-settings/security-settings.md).

The section has four tabs: ***Before opening***, ***After opening***, ***Before closing*** and ***After closing***. Each tab has an event, configured with the settings of the Event group.

### Event

The list at the top of each event defines the action:

* ***None***: no action. This is the default value.
* ***Execute script***: runs a script file.
* ***Execute command-line***: runs a command line.
* ***Automation and scripting***: runs a macro, script or tool entry of the vault, selected in the field next to the list.
* ***Execute PowerShell***: runs a PowerShell script typed in the entry. See [Execute a PowerShell script before opening a connection](https://docs.devolutions.net/rdm/knowledge-base/how-to-articles/execute-a-powershell-script-before-opening-a-connection.md).
* ***Copy username to clipboard***, ***Copy password to clipboard***, ***Copy username and password to clipboard***, ***Copy OTP to clipboard***: copy the credentials or the one-time password of the entry. Offered in the ***After opening*** tab only.
* ***Copy to clipboard (custom)***: copies the text entered.
* ***Prompt message***: shows a message to the user.

<table><thead><tr><th width="220">SETTING</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td><em><strong>Script</strong></em>, <em><strong>Command-line</strong></em></td><td>The script file to run, or the command line to run. Shown with <em><strong>Execute script</strong></em> and <em><strong>Execute command-line</strong></em>.</td></tr><tr><td><em><strong>Wait for exit</strong></em></td><td>Waits until the action ends before continuing. Not shown with <em><strong>None</strong></em>, <em><strong>Prompt message</strong></em> and <em><strong>Copy to clipboard (custom)</strong></em>, nor with <em><strong>Automation and scripting</strong></em> when the selected entry cannot be waited for. Entries that can be waited for include AutoHotkey, AutoIt, command line and PowerShell entries.</td></tr><tr><td><em><strong>Use default working directory</strong></em></td><td>Runs the script or command line in the default working directory. Shown with <em><strong>Execute script</strong></em> and <em><strong>Execute command-line</strong></em>.</td></tr><tr><td><em><strong>Run as administrator</strong></em></td><td>Runs the script or command line with elevated privileges. Shown with <em><strong>Execute script</strong></em> and <em><strong>Execute command-line</strong></em>.</td></tr><tr><td><em><strong>Pre-execution pause</strong></em>, <em><strong>Wait timeout</strong></em>, <em><strong>Post-execution pause</strong></em></td><td>Seconds to wait before running the script or command line, maximum time to wait for it, and seconds to wait after it ends (0 to 300 each). Shown with <em><strong>Execute script</strong></em> and <em><strong>Execute command-line</strong></em>.</td></tr><tr><td><em><strong>PowerShell script</strong></em></td><td>The PowerShell script to run. The <em><strong>Edit</strong></em> button opens an editor. Shown with <em><strong>Execute PowerShell</strong></em>.</td></tr><tr><td><em><strong>Timeout (sec)</strong></em></td><td>Maximum time for the PowerShell script. <em><strong>Before opening</strong></em> tab only.</td></tr><tr><td><em><strong>Message</strong></em></td><td>The message shown to the user. Shown with <em><strong>Prompt message</strong></em>.</td></tr><tr><td><em><strong>Mode</strong></em></td><td><p>What the message asks of the user before the session opens. <em><strong>Before opening</strong></em> tab only:</p><ul><li><em><strong>Default</strong></em>: uses the application setting, shown in parentheses.</li><li><em><strong>Passcode</strong></em>: the user must enter the passcode set in <em><strong>Passcode</strong></em> to continue.</li><li><em><strong>Variable</strong></em>: the user enters a value that the session can use as a variable. Select <em><strong>Protect variable field</strong></em> to mask the value.</li></ul></td></tr><tr><td><em><strong>Copy to clipboard</strong></em></td><td>The text to copy. Shown with <em><strong>Copy to clipboard (custom)</strong></em>.</td></tr></tbody></table>

### Before opening

The ***Miscellaneous*** and ***Port knocks*** groups follow the event.

<table><thead><tr><th width="220">SETTING</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td><em><strong>Power-on mode</strong></em></td><td>Powers on the host before connecting: <em><strong>None</strong></em> or <em><strong>Wake on LAN</strong></em>. Wake on LAN requires the MAC address of the host in the entry, and a host that supports it.</td></tr><tr><td><em><strong>Wait timeout</strong></em></td><td>Seconds to wait for the host to answer after each wake request (1 to 300). Enabled with <em><strong>Wake on LAN</strong></em>.</td></tr><tr><td><em><strong>Retry count</strong></em></td><td>Number of wake requests to send (0 to 300). Enabled with <em><strong>Wake on LAN</strong></em>.</td></tr><tr><td><em><strong>Protocol</strong></em></td><td>Protocol of the port knocks: <em><strong>Default</strong></em>, <em><strong>IPv4</strong></em> or <em><strong>IPv6</strong></em>.</td></tr><tr><td><em><strong>Interval</strong></em></td><td>Milliseconds between two port knocks (0 to 180000).</td></tr><tr><td><em><strong>Verbose level</strong></em></td><td>Level of detail of the port knocking logs.</td></tr><tr><td>Port knocks list</td><td>The ports to knock, in order, each with its <em><strong>Protocol type</strong></em> and <em><strong>Port</strong></em>. Manage them with <em><strong>New</strong></em>, <em><strong>Edit</strong></em>, <em><strong>Delete</strong></em>, <em><strong>Move up</strong></em> and <em><strong>Move down</strong></em>.</td></tr></tbody></table>

### After opening

The ***After opening - Macro*** group follows the event. It types a macro in the session after it opens.

<table><thead><tr><th width="220">SETTING</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>Macro type</td><td>The list at the start of the group: <em><strong>Default</strong></em> (a typing macro entered in the entry) or <em><strong>Link</strong></em> (a macro, script or tool entry of the vault, selected in the <em><strong>Link</strong></em> field).</td></tr><tr><td><em><strong>Execute automatically</strong></em></td><td>Types the macro automatically when the session opens.</td></tr><tr><td><em><strong>Initial wait</strong></em></td><td>Seconds to wait after the session opens before typing the macro (0 to 300).</td></tr><tr><td><em><strong>Typing macro</strong></em></td><td>The keys to type. The <em><strong>Edit</strong></em> button opens an editor and the <em><strong>Help</strong></em> button lists the syntax. See <a href="https://docs.devolutions.net/rdm/knowledge-base/how-to-articles/entry-types-events-settings/event-auto-typing-macro.md">Event auto typing macro</a>. Shown with <em><strong>Default</strong></em>.</td></tr><tr><td><em><strong>Consider line breaks as {ENTER}</strong></em></td><td>Sends the Enter key for each line break of the macro. Shown with <em><strong>Default</strong></em>.</td></tr><tr><td><em><strong>Macro password</strong></em></td><td>A password that the macro can type. Shown with <em><strong>Default</strong></em>.</td></tr><tr><td><em><strong>Delay time {Delay}</strong></em></td><td>Milliseconds that the <code>{DELAY}</code> instruction waits (300 to 60000). Shown with <em><strong>Default</strong></em>.</td></tr><tr><td><em><strong>Command</strong></em></td><td>Milliseconds to wait between two commands of the macro (10 to 60000). Shown with <em><strong>Default</strong></em>.</td></tr></tbody></table>

### Before closing

<table><thead><tr><th width="220">SETTING</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td><em><strong>Confirm on disconnect</strong></em></td><td>Asks the user to confirm before closing the session: <em><strong>Default</strong></em> (the application setting, shown in parentheses), <em><strong>Yes</strong></em> or <em><strong>No</strong></em>.</td></tr></tbody></table>

The event follows this setting.

### After closing

The ***Port knocks*** group follows the event, with the same settings as in the ***Before opening*** tab, except that the interval is set in seconds in ***Interval (secs)***.

See also [Entry types events settings](https://docs.devolutions.net/rdm/knowledge-base/how-to-articles/entry-types-events-settings.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/rdm/knowledge-base/knowledge-base-articles/entry-settings/common-settings/events.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
