Here's what I'm able to do with OpenVPN GUI v 11.12.0.0 in a Windows 10 1903 powershell v5.1.18362.145 script run
manually in administrator mode:
* Automatically connect to an OpenVPN server with the command: & "C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --command connect $ovpn.Config
* Wait for connection to complete by pinging the remote router
* Do some work
* Automatically disconnect with a similar command to the above
However when the script is executed under the auspices of the Task Scheduler, run with administrator privileges and "Run with Highest Privileges" checked (as noted in other forum entries), OpenVPN-gui.exe enters the following in the Event>Windows Logs>Application log:
The description for Event ID 0 from source OpenVPN GUI cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
OpenVPN GUI
Previous instance not yet ready to accept commands. Try again later.
In other forum entries it was suggested that the OpenVPN service be changed from Manual to Automatic, which I have done.
Ideas as to what I haven't tried to get OpenVPN-gui to cooperate when run as a scheduled task?