While @modifiers still make sense to make this much easier, you can do this already using scripting and the WMI API.
An example can be found in the ExitOpusAndWait script in the How to Exit Directory Opus FAQ where it talks about automating shutdown and restart of Opus.
Here's the script code (this is a standalone script that runs outside of Opus, but the same objects and functions will work with scripts inside of Opus):
option explicit
Dim OpusInstallPath
OpusInstallPath = "C:\Program Files\GPSoftware\Directory Opus"
Private Function ProcessIsRunning( wmi, strProcess )
Dim colProcessList
Set colProcessList = wmi.Execquery("Select * from Win32_Process Where Name ='" & strProcess & "'")
If colProcessList.Count > 0 Then
ProcessIsRunning = True
Else
ProcessIsRunning = False
End If
Set colProcessList = Nothing
End Function
Private Function WaitForProcess( wmi, strProcess )
Dim i
WaitForProcess = False
For i = 0 to 100
If ProcessIsRunning( wmi, strProcess ) Then
WScript.Sleep 200
Else
WaitForProcess = True
Exit For
End If
Next
End Function
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Dim wmi
Set wmi = Getobject("Winmgmts:")
If ProcessIsRunning(wmi, "dopusrt.exe") Then
Shell.Run """" & OpusInstallPath & "\dopusrt.exe"" /dblclk=off", 1, TRUE
End If
If ProcessIsRunning(wmi, "dopus.exe") Then
Shell.Run """" & OpusInstallPath & "\dopusrt.exe"" /CMD Close PROGRAM", 1, TRUE
End If
' Wait for dopusrt.exe and dopus.exe to finish shutting down.
Dim AllStopped
AllStopped = False
If WaitForProcess(wmi, "dopus.exe") Then
If WaitForProcess(wmi, "dopusrt.exe") Then
AllStopped = True
End If
End If
If Not AllStopped Then
MsgBox WScript.ScriptName & ": Error -- Opus is still running."
WScript.Quit 1
End If