> 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/agent/guides/remote-desktop-manager/session-commands.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Run commands and check the agent status

Run scripts in remote RDP sessions with Devolutions Agent from Remote Desktop Manager, check the agent status, log off through it and use MCP commands.

When Devolutions Agent runs on a remote Windows machine with its ***RDP Extension***, Remote Desktop Manager shows a ***Devolutions Agent*** menu for the RDP sessions to that machine. From it, you run commands in the remote session (***Execute script***) and check that the agent answers (***Agent status***). Remote Desktop Manager also uses Devolutions Agent to log off the remote session and, on Windows, for the `send_command` tool of its MCP server.

Everything runs through the RDP connection: no PowerShell remoting, WinRM or extra firewall port is needed. Commands run in the remote Windows session of the user who opened the RDP session.

## Where the Devolutions Agent menu is

<table><thead><tr><th width="300">WHERE</th><th>COMMANDS</th></tr></thead><tbody><tr><td>Session tab menu of an RDP session open embedded in Remote Desktop Manager, and the <em><strong>Actions</strong></em> ribbon tab while that session is selected</td><td><em><strong>Devolutions Agent</strong></em> – <em><strong>Execute script</strong></em> and <em><strong>Devolutions Agent</strong></em> – <em><strong>Agent status</strong></em>.</td></tr><tr><td>Right-click menu of one or more RDP entries in the navigation pane (Remote Desktop Manager for Windows)</td><td><em><strong>Devolutions Agent</strong></em> – <em><strong>Execute script</strong></em> runs the script in every selected RDP entry, and <em><strong>Devolutions Agent</strong></em> – <em><strong>Agent status</strong></em>.</td></tr></tbody></table>

The menu is hidden when the system setting ***Disable Devolutions Agent jump*** is selected in ***Administration*** – ***System settings*** – ***Application***, and appears only for RDP sessions.

## Execute a script

1. Open the RDP session to the remote machine, or select one or more RDP entries.
2. Select ***Devolutions Agent*** – ***Execute script***.
3. On the ***Quick script*** tab, choose the ***Script type*** and fill in its fields (see the table below). Click ***Variables*** to insert a variable of the entry.
4. To run the script in entries whose session is not open yet, go to the ***Advanced*** tab, select ***Open all connections*** and set a ***Delay*** in milliseconds between the sessions.
5. Click ***Execute***.

If none of the selected entries has an open session and ***Open all connections*** is not selected, Remote Desktop Manager shows "The current selection has no open sessions and "Open all sessions" isn’t checked."

<table><thead><tr><th width="180">SCRIPT TYPE</th><th>FIELDS AND OPTIONS</th></tr></thead><tbody><tr><td><em><strong>Run</strong></em></td><td>Starts a program, like the Windows <em><strong>Run</strong></em> dialog: <em><strong>Run</strong></em> (program), <em><strong>Arguments</strong></em>, <em><strong>Run as administrator</strong></em>, <em><strong>Change default working directory</strong></em>.</td></tr><tr><td><em><strong>Command-line</strong></em></td><td>Runs commands in <code>cmd.exe</code>: <em><strong>Run</strong></em> (commands), <em><strong>Run as administrator</strong></em>, <em><strong>Keep open</strong></em>, <em><strong>Change default working directory</strong></em>, <em><strong>Fire and forget</strong></em>, <em><strong>Unicode console</strong></em>.</td></tr><tr><td><em><strong>PowerShell</strong></em></td><td>Runs PowerShell: <em><strong>Mode</strong></em> (<em><strong>Command</strong></em> or <em><strong>Filename</strong></em>), <em><strong>Arguments</strong></em>, <em><strong>Run as administrator</strong></em>, <em><strong>No profile</strong></em>, <em><strong>No exit</strong></em>, <em><strong>PowerShell 7</strong></em>, <em><strong>Fire and forget</strong></em>, <em><strong>Unicode console</strong></em>. Windows PowerShell is used unless <em><strong>PowerShell 7</strong></em> is selected; PowerShell 7 must be installed on the remote machine and <code>pwsh.exe</code> must be on its <code>PATH</code>.</td></tr><tr><td><em><strong>Scripts/Tools</strong></em></td><td>Runs a macro, script or tool entry of the vault, selected in <em><strong>Script/Tool</strong></em>. The entry must have <em><strong>Allow running via Devolutions Agent</strong></em> selected in its <em><strong>Advanced</strong></em> settings (off by default).</td></tr><tr><td><em><strong>Message</strong></em></td><td>Shows a message box with the <em><strong>Message</strong></em> text in the remote session.</td></tr></tbody></table>

<table><thead><tr><th width="240">OPTION</th><th>EFFECT</th></tr></thead><tbody><tr><td><em><strong>Fire and forget</strong></em></td><td>Starts the command and returns without waiting for it to finish. Shown only when Devolutions Agent on the remote machine supports it.</td></tr><tr><td><em><strong>Unicode console</strong></em></td><td>Runs the console in Unicode so that non-ASCII output is kept. Shown only when Devolutions Agent on the remote machine supports it.</td></tr><tr><td><em><strong>Run as administrator</strong></em></td><td>Runs the command elevated in the remote session.</td></tr></tbody></table>

Remote Desktop Manager logs each run as "{0} executed via Devolutions Agent" or "{0} executed via Devolutions Agent on {1}".

## Check the agent status

Select ***Devolutions Agent*** – ***Agent status***. The ***Agent status*** window shows:

* ***Devolutions Agent*** with a green check when the agent answers in the session, or a red stop icon when it does not.
* ***Devolutions Agent jump sessions***: the number of hosts opened through this session as a jump host, and their list.

A red stop icon means Devolutions Agent is not installed on the remote machine, its ***RDP Extension*** is off (`Session.Enabled` is `false` in `agent.json`), its service is stopped, or the RDP session was opened before the agent was installed.

## Log off through Devolutions Agent

The ***Log off mode*** of an RDP entry, on its ***Advanced*** tab, decides how Remote Desktop Manager logs off the remote session. The default for new entries is set in ***File*** – ***Settings*** – ***Entry types*** – ***RDP*** – ***Default values*** – ***Log off method***, which is ***Automatic*** by default.

<table><thead><tr><th width="280">VALUE</th><th>HOW REMOTE DESKTOP MANAGER LOGS OFF</th></tr></thead><tbody><tr><td><em><strong>Default</strong></em></td><td>Uses the value of <em><strong>Log off method</strong></em> in the Remote Desktop Manager settings.</td></tr><tr><td><em><strong>Automatic</strong></em></td><td>Through Devolutions Agent when it answers in the session, otherwise with a macro.</td></tr><tr><td><em><strong>Remote Desktop Services API</strong></em></td><td>Through the Remote Desktop Services API, without Devolutions Agent.</td></tr><tr><td><em><strong>Macro</strong></em></td><td>Types the log off keystrokes in the session.</td></tr><tr><td><em><strong>Devolutions Agent</strong></em></td><td>Through Devolutions Agent only.</td></tr></tbody></table>

Entries saved with the value of the older Remote Desktop Manager agent use ***Devolutions Agent***.

## Run commands from the Remote Desktop Manager MCP server

On Windows, the Remote Desktop Manager MCP server offers a `send_command` tool for open RDP sessions: "Execute a PowerShell command on the RDP session using Devolutions Agent on the remote machine." Each command runs in a new PowerShell process, so nothing carries over from one command to the next. The tool returns the exit code and the standard output and error. When the agent does not answer, it returns "Devolutions Agent is not available on the remote machine." See [MCP server](https://docs.devolutions.net/rdm/ribbon-menu-bar/tools/all-tools/mcp-server).

## If it doesn't work

* The ***Devolutions Agent*** menu is missing: the session is not an RDP session open embedded in Remote Desktop Manager, or the system setting ***Disable Devolutions Agent jump*** is selected.
* Nothing happens in the remote session: check that the option ***Disable Devolutions Agent virtual channel*** is cleared in ***File*** – ***Settings*** – ***Entry types*** – ***RDP*** – ***Advanced*** on your computer, then close and reopen the RDP session.
* The remote machine is reached through the console session: Devolutions Agent works only in remote (RDP) sessions.
* More causes and messages: [Troubleshooting](https://docs.devolutions.net/agent/help/troubleshooting.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/agent/guides/remote-desktop-manager/session-commands.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.
