Time taken to complete file copy

I have had some cases where I wanted to know how long a file copy took. It seems the only related option is running the copy from a script that has @confirm:Done on the end. I tried that with the intention that as that popped up, I could read the time taken from the copy dialog.
Two problems.

  1. if the copy dialog is minimised, that @confirm dialog is modal, so no way to show the copy dialog.
  2. if the copy dialog is already showing, I can read the time taken, but the time taken doesn't stop counting when the @confirm dialog pops up. So if I check it an hour after the copy is done, the time taken is still counting thus I don't know how long it took.

It's easier to wrap the Copy command into some JScript, like so:

// https://resource.dopus.com/t/time-taken-to-complete-file-copy/41359

function OnClick(clickData) {
    var cmd = clickData.func.command;
    cmd.deselect = false;
    cmd.RunCommand('Set UTILITY=otherlog');

    DOpus.ClearOutput();

    var scriptStartTime = DOpus.Create().Date();
    DOpus.Output('Start:    ' + scriptStartTime.Format('D#yyyy-MM-dd T#HH.mm.ss'));

    cmd.RunCommand('Copy'); // modify as needed

    var scriptEndTime = DOpus.Create().Date();
    DOpus.Output('End:      ' + scriptEndTime.Format('D#yyyy-MM-dd T#HH.mm.ss'));

    var duration = (scriptEndTime - scriptStartTime) / 1000;
    DOpus.Output('Duration: ' + duration + ' seconds');
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>41359</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>// https://resource.dopus.com/t/time-taken-to-complete-file-copy/41359</instruction>
		<instruction />
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    cmd.deselect = false;</instruction>
		<instruction>    cmd.RunCommand(&apos;Set UTILITY=otherlog&apos;);</instruction>
		<instruction />
		<instruction>    DOpus.ClearOutput();</instruction>
		<instruction />
		<instruction>    var scriptStartTime = DOpus.Create().Date();</instruction>
		<instruction>    DOpus.Output(&apos;Start:    &apos; + scriptStartTime.Format(&apos;D#yyyy-MM-dd T#HH.mm.ss&apos;));</instruction>
		<instruction />
		<instruction>    cmd.RunCommand(&apos;Copy&apos;); // modify as needed</instruction>
		<instruction />
		<instruction>    var scriptEndTime = DOpus.Create().Date();</instruction>
		<instruction>    DOpus.Output(&apos;End:      &apos; + scriptEndTime.Format(&apos;D#yyyy-MM-dd T#HH.mm.ss&apos;));</instruction>
		<instruction />
		<instruction>    var duration = (scriptEndTime - scriptStartTime) / 1000;</instruction>
		<instruction>    DOpus.Output(&apos;Duration: &apos; + duration + &apos; seconds&apos;);</instruction>
		<instruction>}</instruction>
	</function>
</button>

Thanks great idea. I hadn't spent the time investigating scripting.
I'm better at Vb, so for anyone else who wants such a thing, here's what I came up with.

Option Explicit
Function OnClick(ByRef clickData)

	Dim cmd, dtStart, dtEnd, strHrs, strMins, strSecs, strMsg, selItem
	Set cmd = clickData.func.command
	cmd.deselect = false ' Prevent automatic deselection
	strMsg = "Copy" & vbCrLf
	For Each selItem in clickData.func.sourcetab.selected
		strMsg = strMsg & selItem.Name & vbCrLf
	Next
	strMsg = strMsg & "from" & vbTab & cmd.source & vbCrLf
	strMsg = strMsg & "to" & vbTab & cmd.dest & vbCrLf
	'cmd.RunCommand "Set UTILITY=otherlog"
	'DOpus.ClearOutput
	dtStart = Now
	'DOpus.Output "Start    " & dtStart
	cmd.RunCommand "Copy"
	dtEnd = Now
	'DOpus.Output "End      " & dtEnd
	strSecs = DateDiff("s", dtStart, dtEnd)
	strHrs = Int(strSecs / 3600)
	strSecs = strSecs - strMins*3600
	strMins = Int(strSecs / 60)
	strSecs = strSecs - strMins*60
	if strHrs < 10 then
		strHrs = "0" & strHrs
	end if
	if strMins < 10 then
		strMins = "0" & strMins
	end if
	if strSecs < 10 then
		strSecs = "0" & strSecs
	end if
	'DOpus.Output "Duration " & strHrs & ":" & strMins & ":" & strSecs
	strMsg = strMsg & "in" & vbCrLf & strHrs & ":" & strMins & ":" & strSecs
	Msgbox strMsg
	
End Function