On OS X, using VirtualBox's Command Line Interface, how can I instruct a VM to open a URL in a web browser?
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.
Steps
- Start the VM:
VBoxManage startvm "{VM NAME}" --type headless
- 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.
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:
- Start the VM:
VBoxManage startvm "{VM NAME}" --type headless
(no changes) - 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'
精彩评论