All Products
Search
Document Center

Elastic Desktop Service:RunCommand

Last Updated:May 12, 2026

Runs 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 type of the script.

Valid values:

  • RunPowerShellScript :

    Runs a PowerShell script.

  • RunBatScript :

    Runs a Bat script.

RunPowerShellScript

CommandContent

string

Yes

The script content in plaintext or Base64-encoded format.
The Base64-encoded script content cannot exceed 16 KB.

Note

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

ipconfig

Timeout

integer

No

The script execution timeout, in seconds. Default value: 300.
A command times out if the script cannot be run due to issues such as process conflicts, missing modules, or an unavailable Cloud Assistant client. When a command times out, the system forcibly terminates the script process.

3600

ContentEncoding

string

No

The encoding mode of the script content.

Note

If you specify a value that is not a valid enumeration member, the system defaults to PlainText.

Valid values:

  • Base64 :

    Base64 encoding

  • PlainText :

    The content is in plaintext and is not encoded. [Default]

Base64

DesktopId

array

Yes

The IDs of the cloud computers on which to run the script. You can specify up to 50 IDs.
The API call is considered successful if the script runs on at least one of the specified cloud computers. The call fails only if the script fails on all of them.

string

No

The cloud computer ID.

ecd-7w78ozhjcwa3u****

EndUserId

string

No

If you specify this parameter, the command runs with the permissions of the specified end user.

Note

This user must have a session history on the cloud computer. This means the user must have logged in after the cloud computer started and their session was not taken over by another user. This parameter is not supported for Linux cloud computers.

alice

CommandRole

string

No

Response elements

Element

Type

Description

Example

object

The response object.

InvokeId

string

The script execution ID. You can use this ID with the DescribeInvocations operation to query the script's 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

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.