The solution is to write a little piece of code that calls the vboxmanage command of VirtualBox.
This command will be used successively with 3 different parameters:
- List all available network interfaces:
vboxmanage list bridgedifs
- Having selected the wanted interface ( we take the 1st wired interface if exists, otherwise the 1st wireless one), we update the VM with it:
vboxmanage modifyvm "VM Name" --bridgeadapter1 "nic name"
- We the launch our VM:
vboxmanage startvm "VM Name"
You can retrieve on GitHub a C source code targeting a Windows Host.
you can even get an already compiled version (yakpro-vm-start.exe).
It is very easy to adapt this source code for Linux Hosts (you can even write a small php script,or whatever language you like to do the job).
If you enjoyed this post, a small star on GitHub will make me happy …