I created 2 VMs using VirtualBox and I can start them fine as my own user using the following command:
vboxmanage startvm myVM -type headless
but when I try the same command with sudo, or in a systemd service, it returns that it can't find the VM.
I found out this
It fails because you are using sudo. VirtualBox is designed to be run by any user (in the vboxusers group), and sudo runs the command as the root user whose VirtualBox configuration is empty.
But I just don't know how to make it so when run as root (with sudo) to have virtualbox settings present.