Add toolbar buttons with script?

Is there a way to add toolbar buttons with a script?

It doesn't look like there is anything in the reference that will do it. Would I need to have the script edit the ".dop" XML file directly?
If so, how do I get DO to update the toolbar with the changes?
I tried editing the testToolbar.dop file manually and then running "Toolbar testToolbar Update" but it didn't seem to update with the changes.

Does it update the bar if you press the button linked here?
UpdateButtons: Command: UpdateButtons (force icon/toggle-status refresh)

After adding your script to the Scripts section in Preferences you can add a button. In edit mode goto to Function and select the script from the dropdown. This way you don't have to update the button every time the script changes.
This should be done if you place the script in the button itself in the Advanced section.
DOP files can be add to the toolbar by double clicking them.

That didn't seem to work. It says the script is now obsolete and you can run "DOpus.NewCommand.UpdateToggle()" but it did not update it from the toolbar file.

Sorry, I meant I wanted to click a button on the toolbar, and have it add a button to a toolbar with a link to the current folder and some extra commands.

I don't think there is a good way to do that. I wouldn't recommend editing toolbar xml in a script as if you get it wrong you could corrupt your toolbar. But it is one option if you really want to go down that path. You'd probably need to close and reopen the toolbar after the file was modified, and making a backup of the old toolbar would make sense.

The script could create a .dcf file which you then drag to your toolbar, which would be safer.