Automate my Button Script?

I have a button that executes the following tasks when pressed:

//Backup of the TSM folder
Copy D:\Getdown\01_Download\TSM To D:\Anwender\Anwendungsdaten\Firefox UpdateAll UNATTENDED=no WHENEXISTS=merge,skip
DELETE D:\Getdown\01_Download\TSM\Sitzung* RECYCLE FILTER del_older_3week
DELETE D:\Anwender\Anwendungsdaten\Firefox\TSM\Sitzung* RECYCLE FILTER del_older_2week
//Backup of the Dopus-Backup folder
Copy /home\Backup\ To D:\Anwender\Anwendungsdaten\DirectoryOpus\ UpdateAll UNATTENDED=no WHENEXISTS=merge,skip
DELETE D:\Anwender\Anwendungsdaten\DirectoryOpus\Backup* RECYCLE FILTER del_older_9month

My question: Is it possible to automate this process, for example, when starting or closing Dopus? Unfortunately, I have little experience in scripting.


There's an OnStartup scripting event which lets you run things when Opus first runs.

Or OnOpenLister which happens each time a new main window opens.

(You can also run User Commands at startup, without involving scripting, but doing it that way makes it harder to also do other things you'd normally want, like opening a window.)

Thank you for the answer.
It seems that my button script code doesn't work in either JScript or VBS. There's always an error while parsing. Too bad. I'm giving up, as I don't have enough coding- knowledge to implement my plan. Thank you anyway.

I have solved it with my rudimentary programming skills. In case anyone is interested or is facing the same problem:

option explicit

'Called when Directory Opus starts up
Function OnStartup(startupData)
	Dim OpusCmd
	Set OpusCmd = DOpus.NewCommand

'Backup des TSM-Ordners
OpusCmd.RunCommand("Copy D:\Getdown\01_Download\TSM To D:\Anwender\Anwendungsdaten\Firefox UpdateAll UNATTENDED=no WHENEXISTS=merge,skip")
OpusCmd.RunCommand("DELETE D:\Getdown\01_Download\TSM\Sitzung* RECYCLE FILTER del_older_3week")
OpusCmd.RunCommand("DELETE D:\Anwender\Anwendungsdaten\Firefox\TSM\Sitzung* RECYCLE FILTER del_older_2week")

'Backup des Dopus-Backup Ordners
OpusCmd.RunCommand("Copy /home\Backup\ To D:\Anwender\Anwendungsdaten\DirectoryOpus\ UpdateAll UNATTENDED=no WHENEXISTS=merge,skip")
OpusCmd.RunCommand("DELETE D:\Anwender\Anwendungsdaten\DirectoryOpus\Backup\* RECYCLE FILTER del_older_9month")

End Function

Maybe there is a better solution, but at least it works.