VM as Windows Service in Separate Mode?

This is for discussing general topics about how to use VirtualBox.
Post Reply
Jalil
Posts: 6
Joined: 24. Jun 2015, 09:58

VM as Windows Service in Separate Mode?

Post by Jalil »

Version: VirtualBox 5.0
Host: Windows 7

If I run VBoxManage.exe startvm VM001 --type headless as a command line (on User01) and start VirtualBox Manager GUI (VirtualBox.exe on User01) then it shows that VM001 is running, but if I run "VBoxManage.exe startvm VM001 --type headless" as a service (using NSSM) with User01 and launch VirtualBox.exe on User01 then the VirtualBox Manager GUI cannot see that VM001 is running.

How should I force VirtualBox.exe to use an already running VBoxSVC.exe instead of creating a new one on the same User01 session?
Or in other words how to run a VM01 as a headless service and using the Separate Mode to manage it using VirtualBox Manager GUI?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VM as Windows Service in Separate Mode?

Post by scottgus1 »

NSSM command line help webpage has this switch:

Code: Select all

ObjectName: The name of the user account under which the service runs. The default is LOCALSYSTEM.
Maybe you could use this to make the guest run under the right account?

You can also use the Remote Desktop server and a client to see the guest screen while running the guest as a service in another account.

There is another thing to do to get the GUI to notice a service-run guest, but I can't remember what it is. Something with an environment variable, or some such. Hopefully someone who knows will enlighten the both of us :)
Jalil
Posts: 6
Joined: 24. Jun 2015, 09:58

Re: VM as Windows Service in Separate Mode?

Post by Jalil »

scottgus1 wrote:NSSM command line help webpage has this switch:

Code: Select all

ObjectName: The name of the user account under which the service runs. The default is LOCALSYSTEM.
Maybe you could use this to make the guest run under the right account?
That is exactly what I did! I set the service to run as User01 then I started the GUI as User01.
scottgus1 wrote: You can also use the Remote Desktop server and a client to see the guest screen while running the guest as a service in another account.
Yes, I know about it but I want to run the VirtualBox Manager GUI to change the guest settings eg.: Change the Network Adapter (NAT, Bridge, Cable connected,...)
scottgus1 wrote: There is another thing to do to get the GUI to notice a service-run guest, but I can't remember what it is. Something with an environment variable, or some such. Hopefully someone who knows will enlighten the both of us :)
That would be interesting if works well.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: VM as Windows Service in Separate Mode?

Post by noteirak »

What you are trying to achieve goes against the working model of VirtualBox, which is one to isolate user environment and not share VMs.
I don't know if it is possible to achieve what you want but only the devs will be able to answer on this one.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
frank
Oracle Corporation
Posts: 3362
Joined: 7. Jun 2007, 09:11
Primary OS: Debian Sid
VBox Version: PUEL
Guest OSses: Linux, Windows
Location: Dresden, Germany
Contact:

Re: VM as Windows Service in Separate Mode?

Post by frank »

I cannot explain how this works for Windows but on non-Windows systems, it's all about which user is used. The XPCOM code searches for the directory /tmp/.vbox-$USER-ipc. It needs to have permissions to read this directory. The file lock within this directory contains the PID of the current running VBoxXPCOMIPCD service which is responsible for finding the VBoxSVC service. And ipcd is a socket used to communicate with VBoxSVC.

Someone else will have to comment the Windows bits.
mribichich
Posts: 4
Joined: 1. Aug 2016, 20:26

Re: VM as Windows Service in Separate Mode?

Post by mribichich »

Hi there. I been running vboxvmservice along side phpvirtualbox and they show the same vms state. They are both running with the same user.
But when I open vbox gui the state is not shared even though is the same user.

Is there a way to make them share the state?

I know its probably something to do with user permissions, even when I use the same user for everything the service and the gui dont share state.

Anybody knows if there is something to do?

thanks
Post Reply