VirtualBox as a service

Discussions related to using VirtualBox on Windows hosts.
wesmon
Posts: 2
Joined: 12. Oct 2007, 02:25

Me Too

Post by wesmon »

I'm am having a similar issue running it from the scheduler at startup. I tried running the vbmanage exe in the scheduler. I also tried just running a batch file. Both fail. I'm running the job from the same privileged account the created the virtual machines.

If I go to the scheduler and click Run Now, it launches properly.

Running vb1.5, XP host, XP guest.

Any ideas?

thanks
Wes
pg94au
Posts: 4
Joined: 20. Jun 2007, 04:28

Post by pg94au »

If this is going to be suggested as an enhancement, the fix is to actually make it run as a service, not to get it to work somehow as a scheduled task. (Though I realize some people may be interested in this as a temporary solution.)

A model similar to what VMWare Server does would be ideal, where a Windows service is responsible for starting all VMs that are marked as 'start on reboot'.

I'm very impressed by VirtualBox so far, but the inability to run it as a service is an unfortunate omission.
tk
Posts: 1
Joined: 14. Oct 2007, 11:21

VirtualBox as a service

Post by tk »

I'm trying to set up a virtual NAS that allows me to access an ext3 HD via samba running on debian 4 from my WindowsXP host. This works very fine (raw disk access, host interface, etc.) and I also can startup and shutdown the machine using the commands
  • VBoxManage.exe startvm VirtualNAS -type vrdp
    VBoxManage.exe controlvm VirtualNAS acpipowerbutton
from a dos box and also from a batch file. So far so good.

When I put the batch file in a scheduled task at startup (also the non-admin users in my family should be able to access their data when I'm not at home to startup the machine) then I reproducably get
  • VirtualBox VRDP Headless Interface 1.5.0
    (C) 2005-2007 innotek GmbH
    All rights reserved

    Invalid machine name!
    (rc = 0x80070057)
I.e. everything works as described in the (excellent! only a hint of how to find the correct number to put behind PhysicalDrive is missing) documentation. Only the startup of the machine at system startup does not know my machine (yet?).

So, any suggestions from the experts?

http://www.virtualbox.org/discussion/1/670 is somewhat related.
There sombody seems to have gotten it to work, but does not exactly seem to know how.

Scheduling the shutdown command is a different topic on windos XP HOME, but google search for HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System\Scripts seems to provide some useful hints.
roelvdh
Posts: 13
Joined: 8. Jan 2008, 22:21

Post by roelvdh »

dlambeth wrote:Here are my steps:

I type in:
>VBoxVRDP.exe -startvm W3K_DC1

Command promt shows:
VirtualBox VRDP Headless Interface 1.5.0
(C) 2005-2007 innotek GmbH
All rights reserved

Listening on port 3389
Error: failed to start machine. Error message: Failed to launch VRDP server (VERR_NOT_SUPPORTED)
Please use quotes around W3K_DC1. It seems the VB-machine has started (the RDP-server is listening at least). Although the error message suggests something else I would try adding quotes first.
Roel
nullspam
Posts: 3
Joined: 7. Aug 2008, 22:14

Post by nullspam »

Mugwump00 wrote:Do you have an idea on how to get all your running VMs to close to a Saved state when you shutdown/reboot?

I've tried various ways, including yours, but I've no success in getting VB to close down elegantly other than to write a "vboxmanage controlvm" script and use this whenever I want to reboot my server.
There is a way. Use the Group Policy Object Editor (run 'mmc' to 'add' that editor, goto Computer Configuration/Windows Settings/Scripts/Shutdown, copy & add your script) to let windows execute automatically your (vboxmanage controlvm <vm-name> savestate) script at shutdown.

See: http://www.microsoft.com/technet/script ... sion2.mspx for more details.
galaxymike
Posts: 1
Joined: 17. Feb 2009, 06:48

Post by galaxymike »

Hello,
I wish to tell you as I started VirtualBox as service under Windows Vista.

1) run `cmd` and write:
sc create VirtualServer binPath= "%SystemRoot%\System32\srvany.exe" start= auto DisplayName= "Virtual Server"
2) run `regedit` and goto '[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VirtualServer]'
2.1) add section 'Parameters'
2.2) add key 'Application' equal 'C:\Program Files\Sun xVM VirtualBox\VBoxHeadless.exe' to section 'Parameters'
2.3) add key 'AppParameters' equal 'startvm <vmname> -vrdp=off' to section 'Parameters'
2.4) add key 'AppDirectory' equal 'C:\Program Files\Sun xVM VirtualBox\' to section 'Parameters'
3) run `mmc` and goto 'Computer Configuration/Windows Settings/Scripts/Shutdown' and add script with line:
vboxmanage controlvm <vmname> savestate
4) copy '.VirtualBox' from 'C:\Users\<username>\' to 'C:\Windows\System32\config\systemprofile\'

Enjoy!

P.S.: Obtain copy of srvany.exe from the appropriate Windows Resource Kit.
jdl
Posts: 10
Joined: 15. Dec 2008, 22:09

Re: VirtualBox as a service

Post by jdl »

galaxymike wrote:Hello,

I wish to tell you as I started VirtualBox as service under Windows Vista.


1) run `cmd` and write:

sc create VirtualServer binPath= "%SystemRoot%\System32\srvany.exe" start= auto DisplayName= "Virtual Server"

2) run `regedit` and goto '[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VirtualServer]'

2.1) add section 'Parameters'

2.2) add key 'Application' equal 'C:\Program Files\Sun xVM VirtualBox\VBoxHeadless.exe' to section 'Parameters'

2.3) add key 'AppParameters' equal 'startvm <vmname> -vrdp=off' to section 'Parameters'

2.4) add key 'AppDirectory' equal 'C:\Program Files\Sun xVM VirtualBox\' to section 'Parameters'

3) run `mmc` and goto 'Computer Configuration/Windows Settings/Scripts/Shutdown' and add script with line:

vboxmanage controlvm <vmname> savestate

4) copy '.VirtualBox' from 'C:\Users\<username>\' to 'C:\Windows\System32\config\systemprofile\'


Enjoy!

P.S.: Obtain copy of srvany.exe from the appropriate Windows Resource Kit.
srvany.exe, from what I have read, does not work under Windows Server 2008 64-bit. We desperately need a way to run these applications as services!!! Has anyone had any success either with this method or other methods? Anyone know if and when VirtualBox will support the ability to run its machines as individual services?

Thanks!!!!!!!!!
sleewok
Posts: 12
Joined: 14. Aug 2009, 20:22
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Windows 7, Ubuntu Server

Re: VirtualBox as a service

Post by sleewok »

Ran across this in another forum (http://social.technet.microsoft.com/For ... 77899cf7de):

I, too, am wanting to use a "svrany" situation on Windows Server 2008, but couldn't find anything much more useful than this thread! (Yes, that is pathetic!) ... other than some references (etc.) to "sc". So after much banging of my head against a wall with "sc", I decided to experiment , and ... SUCCESS!!!

Here's what to do ...

1. At the time of this posting, there is no Windows Server 2008 Resource Kit Tools, so get the "srvany.exe " from the "Windows Server 2003 Resource Kit Tools " and copy it to a suitable location on your Win2008 server (e.g. C:\Windows\System32\ ).
2. Use "sc " to create a new service that launches "srvany " (e.g. sc create MyService binPath= C:\Windows\System32\srvany.exe DisplayName= "My Custom Service" )
3. Using RegEdit : create a "Parameters " key for your service (e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\Paramaters\ )
4. Using RegEdit : within the newly created "Parameters " key , create a string value called "Application " and enter the full path to the application you are wanting to run as a service. (No quotes required.)


And that should do it.

Note : some applications store their settings in a user hive, not under HKEY_LOCAL_MACHINE, so you will need to run the application to configure it, and then configure the service to run as that user.

Enjoy!
jgcertified
Posts: 1
Joined: 18. May 2010, 09:01
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows NT 4.0

Re: VirtualBox as a service

Post by jgcertified »

Hi guys, I'm currently working on an application / Windows Service that will allow you to run VirtualBox VM's as a Windows Service

It's currently pre-pre alpha, but once it's together I shall put it up for download :)
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VirtualBox as a service

Post by mpack »

jgcertified wrote:Hi guys, I'm currently working on an application / Windows Service that will allow you to run VirtualBox VM's as a Windows Service
What's wrong with the VBoxVmService tool described in the sticky at the top of this forum?
theGleep
Posts: 11
Joined: 19. May 2010, 23:16
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Windows 2000, Ubuntu Linux, Windows XP

Re: VirtualBox as a service

Post by theGleep »

I've been able to do this by following these instructions:

http://www.tacktech.com/display.cfm?ttid=197

I point "Application" to a batch file:

Code: Select all

cd "c:\program files\sun\virtualbox"

start /b /wait /low vboxheadless -startvm "! Win2k"
The last thing I had to do was to copy my .virtualbox folder from my personal folder ("C:\Documents and Settings\earl.brown") to the LocalService account folder ("C:\Documents and Settings\LocalService")

(To do that, you will need to show system files and folders)

Now it's working just fine.

With a little exception - I can't shut it down by saving state. I think I can reconfigure the service to use my personal login, then the guest states will be updated in my .virtualbox folder, instead of the LocalService folder.
sub2k1
Posts: 1
Joined: 16. Dec 2010, 19:54
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Ubuntu 10.04 Server

Re: VirtualBox as a service

Post by sub2k1 »

I know this is an old thread but I choose to bump it because it is the first hit in Google. I've not had much success starting VirtualBox as a service, then again I didn't want VirtualBox to be invisible on the system. I've come up with an easy alternative method to answer the original poster's question. I am using Windows XP Home SP3 as a primary operating system. I've setup Ubuntu 10.04 Server to run as my guest OS in VirtualBox. Now when I turn on my computer Windows XP automatically logs into my "server" account and launches VirtualBox, then automatically locks the account returning me to the Fast User Switching screen. If you are an advanced user then please forgive me for making you read all this, its five easy steps.:

BASICS:
Step 1: Create an administrative account named vbox
Step 2: Set vbox to autologin when Windows starts.
Step 3: Create a batch file in your startup directory
Step 4: Copy and paste code listed in walk-through. Modify as needed.
Steps 5 & 6: Save the batch file and restart the PC.

WALK-THROUGH:
Step 1. Create an administrative account named vbox (or you can call it whatever you please)
a. Start Menu --> Run --> Type: 'control userpasswords2' (without the ' ' marks)
b. Click Add button
c. User Name: vbox
d. Click Next
e. Enter in any secure password of your choosing and click Next.
f. Select 'Other' radial and then select Administrators.
g. Click Finish

Step 2. Set vbox to autologin when Windows starts.
a. In User Accounts, uncheck the box that says 'Users must enter a user name and password to use this computer."
b. In the popup window titled 'Automatically Log On' enter the User name, Password, and Confirmation of the vbox account and then select Ok.
c. Click Ok in the User Accounts window.

Step 3. Create a text file under the startup directory in the start menu.
a. Click the Start Menu
b. Select 'All Programs'
c. Right-click on the Startup folder and select Open
d. Right-click on an empty space in the Startup window and select New then click Text Document.
e. Name the new document launcher.
f. Open the launcher file (in notepad)

Step 4. Copy and paste the following code into the document and modify the directory and GUESTOS field to match location of VBoxManage.exe and the name of your Guest OS in VirtualBox.
Note: For example my GuestOS is named LinuxServ 10.04 in VirtualBox so my fourth line says:
C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "LinuxServ 10.04"
Your line should be different.

Code: Select all

@echo off

echo Please do not touch the keyboard or mouse at this time.
echo Now launching VirtualBox...
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "GUESTOS"

cls
echo VirtualBox has been launched!!!
echo Locking account. You will be returned to the Login Screen.
rundll32.exe user32.dll, LockWorkStation
exit
Step 5. Save the text file as a batch file
a. Click File and select Save As..
b. Filename: launcher.bat
c. Save Type As: All Files
d. Click Save

Step 6. Close out of Notepad and delete the original launcher file launcher.txt (it may just say launcher and have a notepad icon on it). Go ahead and restart your pc and watch her go.
ehnatone
Posts: 1
Joined: 21. Dec 2010, 00:23
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu Server 10.10

Re: VirtualBox as a service

Post by ehnatone »

I'm so lucky that you've just refired this post! It gives hope! :D Thanks!

So, i've created a service, on Windows7, for VBox 3.2.12, running Guest OS Ubuntu Server 10.10 in the following way:

Code: Select all

C:\Windows\system32>sc create vmsvc1 binPath= "c:\progra~1\oracle\virtua~1\vboxmanage.exe startvm ubuserv -type vrdp" start= auto DisplayName= "Virtual Server UbuServ Autostart Service 1"
[SC] CreateService SUCCESS
however, if i start the service, it just keeps me annoyed with the error message below, unfortunately.
Windows could not start the Virtual Server UbuServ Autostart Service 1 service on Local Computer.
Error 1053: The service did not respond to the start request in a timely fashion.
So the fashion above for about few days of searching just keeps me annoyed and makes me scream.
Tried to specify other type of path string also, but it refers to missing files, it just won't work anyway :(
If I start the VM manually with the command below, not as a service, the good old black box appears, VM runs, and is available fo rdp. :)

Code: Select all

C:\Windows\system32>c:\progra~1\oracle\virtua~1\vboxmanage.exe startvm ubuserv -type vrdp
What am i missing here?

Thanks!
Ehnatone
Isomillennium
Posts: 1
Joined: 2. Feb 2011, 15:50
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: OpenSuse 11.3

Re: VirtualBox as a service

Post by Isomillennium »

Hello,

I have gotten this to work beatifully with serviceex...

Heres my configuration and what i have done to get this up and working...

1. download serviceex from http://www.serviceex.com

2. Save serviceex executable file [serviceex.exe] and the ini file that it came with to a folder of your wish [ex. c:\serviceex\]

3. Edit the ini file in c:\serviceex\

4. Here is what mine looks like

Code: Select all

[ServiceEx]
ServiceExeFullPath = "C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe"

; program arguments to be sent to executable
options = --startvm "OpenSuse 11.3 Server" ; Put your virtual machine name in quotes

; can program interact with desktop [true | false] (default: true)
desktop = true

; start type (valid values: Auto Manual Disabled) (default: auto)
Start = auto

; start the service upon installation [true | false] (default: no)
StartNow = false
5. Make sure to save this file with a descriptive name for ex "VBoxServer.ini"
6. Open up a command promt with admin privileges. Usually right click on cmd.exe and "run as admin".
7. cd to the directory where serviceex.exe and ini files are. ex. cd c:\serviceex
8. type serviceex install VBoxServer.ini [replace vboxserver with the ini file you saved your file as]
9. NOw create a shortcut for services.msc on the desktop. then right click on it and run as admin..
10. Find VBoxServer service and click properties..
11. Click on log on tab and hit "This Account and specify your username [The username Your virtual mchines are installed with] and type password then confirm and hit OK.
12. Try starting it....

Let me know if you run into more problems....
pacs101
Posts: 2
Joined: 15. Aug 2011, 14:39
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Debian, openSuSE,...

New Service-Wrapper-Application available

Post by pacs101 »

Since I wasn't quite comfortable with the existing solutions, I just build my own Windows-Service-Wrapper for VirtualBox 4.1

Instructions, Download (free and OpenSource) and more Details: http://code.google.com/p/vboxservice4windows

There's a pre-compiled version available which should be working on Windows 7 SP1 (32- & 64-Bit tested).

In case you have any problems, please submit an issue on google-code.
Post Reply