Start a VM with the webcam on

Discussions related to using VirtualBox on Linux hosts.
Post Reply
sancho_s
Posts: 1
Joined: 10. May 2020, 19:58

Start a VM with the webcam on

Post 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?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Start a VM with the webcam on

Post 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.
Post Reply