All Products
Search
Document Center

Elastic Desktop Service:RunCommand

Last Updated:Sep 04, 2026

Executes a PowerShell or Bat script on one or more cloud computers that run Windows.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecd:RunCommand

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID.

cn-hangzhou

Type

string

Yes

The language type of the O&M script.

Valid values:

  • RunPowerShellScript :

    Run a PowerShell script.

  • RunBatScript :

    Run a Bat script.

RunPowerShellScript

CommandContent

string

Yes

The plaintext or Base64-encoded content of the script.
The Base64-encoded script content cannot exceed 16 KB.

Note

If the script content is Base64-encoded, set the ContentEncoding parameter to Base64.

ipconfig

Timeout

integer

No

The timeout period for executing the script. Unit: seconds. Default value: 300.
A timeout may occur when the script cannot run because of process issues, missing modules, or a missing Cloud Assistant client. After a timeout, the script process is forcefully terminated.

3600

ContentEncoding

string

No

The encoding method of the script content.

Note

If the specified value is not within the valid values, the value is treated as PlainText.

Valid values:

  • Base64 :

    Base64-encoded.

  • PlainText :

    Not encoded. The content is transmitted in plaintext. [Default]

Base64

DesktopId

array

Yes

The list of cloud computer IDs. Valid values of N: 1 to 50.
If multiple cloud computers are specified, the API call succeeds as long as the script is successfully executed on at least one cloud computer. If the script fails to execute on all specified cloud computers, reset this parameter.

string

No

The cloud computer ID.

ecd-7w78ozhjcwa3u****

EndUserId

string

No

The ID of the end user. If this parameter is specified, the command is executed with the permissions of the end user.

Note

The user must have a session record on the cloud computer (the user has logged on and connected to the cloud computer after it was started, and the session was not preempted by another user). This parameter is not supported for Linux cloud computers.

alice

CommandRole

string

No

The role used when the command is executed on the cloud computer.

system

Response elements

Element

Type

Description

Example

object

The response object.

InvokeId

string

The script execution ID. You can call DescribeInvocations and pass in this value to query the script execution status.

t-hz01qgsqj2n****

RequestId

string

The request ID.

1CBAFFAB-B697-4049-A9B1-67E1FC5F****

Examples

Success response

JSON format

{
  "InvokeId": "t-hz01qgsqj2n****",
  "RequestId": "1CBAFFAB-B697-4049-A9B1-67E1FC5F****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidCmdType.MisMatch The specified instance type does not match the command. The specified instance type does not match the command.
400 InvalidDesktopId Invalid desktop id found, please check. Invalid desktop id found, please check
400 InvalidEndUser.NotFound End user is not found. End user is not found

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.