# How to use AddButtonsData.embedded?

**URL:** <https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488>\
**Category:** Help & Support\
**Tags:** commands, jscript\
**Created:** [May 23, 2026, 10:55am UTC](https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488 "2026-05-23T10:55:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![a815](https://resource.dopus.com/letter_avatar_proxy/v4/letter/a/cdc98d/32.png) [@a815](https://resource.dopus.com/u/a815)\
**Post date:** [May 23, 2026, 10:55am UTC](https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488/1 "2026-05-23T10:55:20Z")

</div>

Hi,

I want to add embedded command support for dynamic buttons in script commands, but `AddButtonsData.embedded` always returns an empty string. I don't know if I misunderstand how this property is used, and I haven't found any examples using this property.

I noticed this feature was added in stable version [13.16](https://resource.dopus.com/t/directory-opus-13-16/56034). I tried installing 13.16, but it still doesn't work. I don't know if I'm using it wrong, or if this feature has never worked correctly.

Here is a simple script that adds the `MyCommand` command, with the `DYNAMIC` parameter being the dynamic button parameter.  
The output of embedded is an empty string.

```js
function OnInit(initData) {
    initData.name = 'MyDynamicCommand';
    initData.version = '1.0';
    initData.default_enable = true;
    initData.min_version = '13.0';
}

function OnAddCommands(addCmdData) {
    var cmd = addCmdData.AddCommand();
    cmd.name = 'MyCommand';
    cmd.method = 'OnMyCommand';
    cmd.desc = '';
    cmd.label = 'MyCommand';
    cmd.template = 'DYNAMIC/S';
    cmd.dynamic_args = 'DYNAMIC';
    cmd.hide = false;
    cmd.icon = 'script';
}

function OnMyCommand(scriptCmdData) {}

function OnAddButtons(addButtonsData) {
    DOpus.Output('cmdline: ' + addButtonsData.cmdline);
    DOpus.Output('embedded: ' + addButtonsData.embedded);
    var button = addButtonsData.buttons.AddButton();
    button.label = 'My Button';
    return true;
}

```

_my button:_

```js
MyCommand DYNAMIC
[Set NOOP]

```

_log:_

```txt
 MyDynamicCommand: cmdline: MyCommand DYNAMIC
 MyDynamicCommand: embedded: 

```

Thanks.

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [May 25, 2026, 6:51am UTC](https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488/2 "2026-05-25T06:51:11Z")

</div>

Thanks, we'll make this work in the next update.

---

<div class="post-metadata">

**Author:** ![aussieboykie](https://resource.dopus.com/user_avatar/resource.dopus.com/aussieboykie/32/23729_2.png) [@aussieboykie](https://resource.dopus.com/u/aussieboykie)\
**Post date:** [May 25, 2026, 8:04am UTC](https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488/3 "2026-05-25T08:04:23Z")

</div>

Once the fix is in place it would be nice to see a simple practical example in the documentation.

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [May 25, 2026, 8:06am UTC](https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488/4 "2026-05-25T08:06:06Z")

</div>

The example above is probably as simple as it gets 🙂

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [May 25, 2026, 8:09am UTC](https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488/5 "2026-05-25T08:09:51Z")

</div>

> [@aussieboykie](#):
>
> Once the fix is in place

It's in the beta we put out today:

> Added `ScriptCommand.supportembedded` property. Set to `true` when adding a dynamic command that you want to be able to support embedded functions.

---

<div class="post-metadata">

**Author:** ![a815](https://resource.dopus.com/letter_avatar_proxy/v4/letter/a/cdc98d/32.png) [@a815](https://resource.dopus.com/u/a815)\
**Post date:** [May 25, 2026, 11:55am UTC](https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488/6 "2026-05-25T11:55:24Z")

</div>

Thanks Jon and Leo, it works perfectly!

> [@aussieboykie](#):
>
> a simple practical example

Let me introduce how I’m used.

With embedded commands, the script only needs to do simple parameter replacements when adding buttons, while the actual button commands are defined in the embedded commands.

In this way, if you need to modify the command a button runs, you only need to change the embedded command, without touching the script.

A simple example:

```js
function OnAddCommands(addCmdData)
{
	var cmd = addCmdData.AddCommand();
	cmd.name = "MyCommand";
	...
	...
	cmd.supportembedded = true; // <-------- set to true
}

function OnAddButtons(addButtonsData)
{
	var embedded = addButtonsData.embedded;
	var paths = [
		"C:\\Users\\",
		"C:\\Windows\\",
		"D:\\"
	];
	for(var i = 0; i < 3; ++i) {
		var button = addButtonsData.buttons.AddButton();
		button.label = paths[i];
        // Use regEx, as JScript does not have the replaceAll() method
		button.func = embedded.replace(/\{\$1\}/g, paths[i]); 
	}
	return true;
}

```

Button Command:

```js
MyCommand DYNAMIC
[
@keydown:none
Go "{$1}" NEWTAB
@keydown:ctrl
explorer.exe "{$1}"
]

```

If my script needs to generate dynamic buttons from some paths obtained somewhere, I can just set `button.func` to the command defined in the embedded command and then replace the parameters, without hardcoding them into the script or passing complex commands through normal parameters.

Hope this helps you 😀.

---

<div class="post-metadata">

**Author:** ![aussieboykie](https://resource.dopus.com/user_avatar/resource.dopus.com/aussieboykie/32/23729_2.png) [@aussieboykie](https://resource.dopus.com/u/aussieboykie)\
**Post date:** [May 25, 2026, 11:14pm UTC](https://resource.dopus.com/t/how-to-use-addbuttonsdata-embedded/59488/7 "2026-05-25T23:14:37Z")

</div>

> [@a815](#):
>
> Hope this helps you 😀.

Very much so. Thanks.
