Page 1 of 1

Start a VM with the webcam on

Posted: 10. May 2020, 20:09
by sancho_s
I am using VirtualBox Graphical User Interface Version 6.1.6_Ubuntu r137129, under Ubuntu 20.04, with a guest OS Win 10 (although this is likely irrelevant).

I have found how to use a webcam in the guest, using the extension pack (I managed to do this having both installed package virtualbox-ext-pack and added the package via File -> Preferences in Virtualbox; I am not sure both are needed at the same time).
This requires as a last step to attach the webcam to the VM, via command line. But for that command to be valid, the VM has to be running, otherwise an error pops

Code: Select all

$ VBoxManage controlvm "Win10" webcam attach .1
VBoxManage: error: Machine 'Win10' is not currently running
As an alternative to the last step, with the VM running, I can go to Devices -> Webcams -> Tick the checkbox.

In any of the two cases, whenever the VM is shut down, and later restarted, the webcam starts detached, and the last step (either via CLI or VM menus) has to be manually performed.

Is there any way to get the webcam on/attached by default?

Re: Start a VM with the webcam on

Posted: 10. May 2020, 20:47
by scottgus1
I can't speak to whether there is a way to have the Webcam attached by default, but since you found the command line to attach the webcam, you could look through the manual to see if there is such an automatic option. Or use a batch file to start the guest, wait until the guest is running (monitor 'vboxmanage showvminfo "vmname" ' for "state: running") then command the webcam.