3

I'm running VirtualBox Version 4.2.0 r80737.

I have a USB keyboard that I usually just want filtered to the VirtualBox, but occasionally I want to free it up so that I can use it in the host OS as well. I was looking at VBoxManage in the documentation, and saw the promising looking "usbfilter" option, but when I tried usbfilter add/modify I got the error:

The machine 'your name here' is already locked for a session (or being unlocked)

So it seems that it doesn't affect the running machine (at least not through that option). I really just want to be able to programatically do the same thing as going through the menu to Devices > USB Devices > USB Keyboard [0001].

I don't care whether it's from the host or guest OS that I can access it.

Is this possible, and if so, how can I do it?

4

This is done with usbattach command as described in manual.

VBoxManage controlvm <VM_ID> usbattach <uuid>|<address>
VBoxManage controlvm <VM_ID> usbdetach <uuid>|<address>

In order to find your VM ID, run VBoxManage list vms

For list of USB device UUIDs, run VBoxManage list usbhost (you may need to add sudo)

  • That looks more promising. Now I just need to find my UUID/address. So far I've failed to find anything useful. – Wayne Werner Dec 6 '12 at 15:07
  • 2
    And just after I wrote that I discovered VboxManage list usbhost. Hooray! It works! – Wayne Werner Dec 6 '12 at 15:10
  • The command you posted seems to be missing an argument as it didn't work for me. If you update your answer let me know, I'll delete mine. – csga5000 Nov 16 '17 at 23:04
  • @csga5000 Thanks for pointing that out, I have edited my answer. – Volodymyr Smotesko Nov 17 '17 at 9:17
  • @WayneWerner I have added list usbhost to the answer, thanks! – Volodymyr Smotesko Nov 17 '17 at 9:18
0

The other answer didn't work "out of the box" so here's what I got from his answer combined with looking at vboxmanage help:

(You may need to do: vboxmanage.exe, or cd \your\vbox\dir .\vboxmanage)

vboxmanage list vms
# Find your vm in the list and note the left string (ex "some_machine_123412341234_12345")
vboxmanage list usbhost
# Find your device in that list and note the uuid
vboxmanage controlvm "some_machine_123412341234_12345" usbattach "DEVICE_UUID"

Or to detach:

vboxmanage controlvm "some_machine_123412341234_12345" usbdetach "DEVICE_UUID"

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.