This script is used to start my VirtualBox VMs. It will first check if the VM is running already, if so it will switch to its workspace it via the i3switch script and otherwise it will first start it, then wait for a few seconds (this needs to be adjusted to your environment) and then call the already mentioned vboxputmount script to have the disk encryption password be entered.
#!/bin/bash
wanted=$1
if vboxmanage showvminfo $wanted --machinereadable | grep -Fxq 'VMState="running"'; then
i3switch -o $wanted
else
vboxmanage startvm $wanted
sleep 3
vboxputmount $wanted
fi