Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On OS X, using VirtualBox's Command Line Interface, how can I instruct a VM to open a URL in a web browser?

Tags:

virtualbox

From Terminal in Mac OS X, I want to use VBoxManage guestcontrol to control Windows XP in a VirtualBox Virtual Machine, to open a URL in Internet Explorer.

like image 855
Jamie Mason Avatar asked Sep 09 '11 14:09

Jamie Mason


2 Answers

Steps

  1. Start the VM: VBoxManage startvm "{VM NAME}" --type headless
  2. Open the URL: VBoxmanage guestcontrol "{VM NAME}" exec "{SHORT PATH TO THE BROWSER}" --username "{USER NAME}" --password "{PASSWORD}" "{URL TO OPEN}".

Headless

The --type headless option is optional, if you want to see what's happening you can omit this.

Getting the short name

An easy way to get the short path to the browser is to open cmd.exe and run; cd "{NORMAL LONG PATH TO BROWSER}" then command and the short path name will be displayed.

Params

  • {VM NAME} == Case sensitive name of the virtual machine.
  • {USER NAME} == System User name on the guest running on the VM, not the displayed name.
  • {PASSWORD} == Password for the above account
  • {URL TO OPEN} == eg: https://stackoverflow.com/
  • {SHORT PATH TO THE BROWSER} == eg: C:\DOCUME~1\JAMIE~1\LOCALS~1\APPLIC~1\GOOGLE\CHROME\APPLIC~1\chrome.exe

Example

To open IE9 from the VM available from https://github.com/xdissent/ievms

VBoxmanage guestcontrol 'IE9 - Win7' exec 'C:\Progra~1\Intern~1\iexplore.exe' --username 'IEUser' --password 'Passw0rd!' 'http://google.com'

Credit

Thanks to http://www.quora.com/Chapley-Watson for this answer, I'd searched all over the place including Stack Overflow and got no replies. Hopefully this will help someone.

like image 185
Jamie Mason Avatar answered Jan 01 '23 21:01

Jamie Mason


Completing fold_left answer for new version of VBox 5.0.2

With new version they have changed some commands. The process will be as follows:

Steps:

  1. Start the VM: VBoxManage startvm "{VM NAME}" --type headless (no changes)
  2. Open the URL: VBoxmanage guestcontrol "{VM NAME}" start --exe "{SHORT PATH TO THE BROWSER}" --username "{USER NAME}" --password "{PASSWORD}" -- iexplore "{URL TO OPEN}". (new commands)

Example

To open IE9 from the VM available from https://github.com/xdissent/ievms

VBoxmanage guestcontrol 'IE9 - Win7' start --exe 'C:\Progra~1\Intern~1\iexplore.exe' --username 'IEUser' --password 'Passw0rd!' -- iexplore 'http://www.wikipedia.org'

like image 21
Cristobal-io Avatar answered Jan 01 '23 23:01

Cristobal-io