start-process ‘C:\Program Files\Oracle\VirtualBox\vboxheadless’ ‘-s yourVMNameHere‘ -WindowStyle Hidden
This powershell command will start your virtualbox machine. We’re going to set things up so you can do it by clicking on an icon.
Your Mileage May Vary: The stuff below worked great at work, but I’ve yet to work out why it doesn’t on my machine at home..
VBoxHeadless.exe: error: Code E_FAIL (0x80004005) - Unspecified error (extended info not available) Context: "PowerUp(progress.asOutParam())" at line 1138 of file VBoxHeadless.cpp
A while back I posted about starting a virtualbox virtual machine without having the console, or the vbox manager, or a dos box hanging around. It’s a strangely popular post?! I just want to click an icon and my virtual machine starts and I don’t see it. Either it just does it’s thing, or I ssh into it; like a real server. Seems I’m not alone. That method is long in the tooth. This works for me on Windows 7…
1. The powershell script
Start -> Notepad
and put the following into the file. Substitute “myVMNameHere” for the name of your virtual machine (as it appears in bold in the virtualbox manager):
start-process 'C:\Program Files\Oracle\VirtualBox\vboxheadless' '-s myVMNameHere' -WindowStyle Hidden
Save to your desktop with the filename extension of “.ps1″. eg: “myVMName.ps1″
2. Set powershell scripts executable
You only need to do this once, perhaps not at all. By default windows does not permit users to execute their powershell scripts. You probably need to have permission to set the permission.
Start -> powershell -> right click -> run as administrator
And type in:
Set-ExecutionPolicy RemoteSigned
And say “Y” for yes.
3. Right-click -> “Run with Powershell”
To run it right click on the icon and you should get a “Run with powershell” option. Do that.
Trouble
- If you have the virtualbox manager open, the preview is updated realtime so you can sort of see what is currently on the machine console.
- If the machine won’t start open the script (right-click -> edit) replace the “-WindowStyle Hidden” option with “-RedirectStandardError filename”. Then run it. The error output will appear in a new file named ‘filename’ on your Desktop.
- Looking at the error output generally told me nothing useful. Problems are probably permissioning issues. Run powershell as administrator and see what happens when you type the command in manually. I’ve had a dialog from Windows Firewall come up and need clearing on some machines.
- open the task manager and look for, and/or kill, the “vboxheadless.exe” process.