Starting the Autostart Service With a Windows service

Discussions related to using VirtualBox on Windows hosts.
Post Reply
mnr989
Posts: 3
Joined: 19. Sep 2022, 21:44

Starting the Autostart Service With a Windows service

Post by mnr989 »

(mod edit: former topic title: (gui/vboxmanage.exe locked out of managing Virtualbox")

Does anyone have any guidance on user management for Oracle VirtualBox?

Any documentation?



I'm in a situation where I configured task scheduler in windows to AutoStart my VM when Windows boot.



This situation only occurs when this task auto runs on startup.

Please note the settings for my task in Task Scheduler , I chose "Run whether user is logged on or not, and Run with highest privileges is selected.

Now this aspect is working flawlessly. The only problem is when I use command line utility VboxManage.exe or even the GUI to manage my VMs, they both lack the ability to see my existing VMs or running VMs.


I do want this AutoStart feature to be successful, but I also want to use command line and gui to manage the affairs of VirtualBox without being locked out per se.
After the vm has autostarted in this manner, my plan is to use scripts and vboxmanage.exe to manage affairs of VirtualBox. Can't do any of that while "locked out"

Any advice or knowledge?
Thanks
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: gui/vboxmanage.exe locked out of managing virtualbox

Post by scottgus1 »

Virtualbox typically runs its VMs in the logged-on user account. However this:
mnr989 wrote:Run whether user is logged on or not, and Run with highest privileges
uses a different account than the logged-in account, probably the System account.

Vboxmanage and the main Virtualbox window can only affect the VMs started in the logged-in account. So the Task-Scheduler-started VM can't be adjusted by Vboxmanage and the main Virtualbox window.

See https://www.virtualbox.org/manual/ch09. ... rt-windows for Virtualbox's autostart method. I haven't used this method though, so I don't know if this method allows Vboxmanage / main Virtualbox window operation.
mnr989
Posts: 3
Joined: 19. Sep 2022, 21:44

Starting the Autostart Service With a Windows service

Post by mnr989 »

In my original post: viewtopic.php?f=6&t=107153

I've been led here to official documentation: https://www.virtualbox.org/manual/ch09. ... rt-windows

What I am finding difficult are these instructions. For example, I don't know where to find the configuration file needed to make these changes or additions.

I wish to use the official method listed to achieve success. Does anyone have a guided tutorial or was successful doing the AutoStart of the VM using this method?

This method seems most promising because I would not have lost control of the Virtualbox GUI or VBoxManage.exe as highlighted in my original post.

Thanks
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: gui/vboxmanage.exe locked out of managing virtualbox

Post by scottgus1 »

Merged topics and changed topic title. Also moved to Windows Hosts, since it's a host configuration issue.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Starting the Autostart Service With a Windows service

Post by scottgus1 »

mnr989 wrote:I don't know where to find the configuration file needed to make these changes or additions.
From the manual:
The configuration file should be located in a folder accessible by all required users but it should have permissions allowing only reading by everyone but administrators.
......
add the VBOXAUTOSTART_CONFIG environment variable into system variables containing the path to the configuration file described above. The environment variable tells the autostart services which configuration file is used.
So it appears that you'd make a basic Notepad text file with appropriate contents in a public folder, then make the system variable containing the configuration file's path and name.

Example:
New folder "C:\VMautostart" with permissions: Admin full control, Everyone read only
Notepad file in C:\VMautostart, containing config info, called "VMconfiginfo.txt"
New system variable VBOXAUTOSTART_CONFIG, containing the value C:\VMautostart\VMconfiginfo.txt
mnr989
Posts: 3
Joined: 19. Sep 2022, 21:44

Re: Starting the Autostart Service With a Windows service

Post by mnr989 »

@scottgus1 I am grateful for your response. I was able to use your input to generate some success, mixing it the the advice from this link under "Answers 3 : of Start VirtualBox and VM in windows boot": https://www.anycodings.com/1questions/4 ... ndows-boot

Please allow me to elaborate.
I have had success with doing this on Windows 11.
I just created the folder as you said and applied the appropriate permissions stated.
At first I was getting this error when I attempted to run the service from services.msc : "a device attached to the system is not functioning".
I fixed this by making my windows user defined an Administrator and this solved the problem perfectly. I even test restarted the computer and I have verified that the VM autostarts even before I log into the desktop of that defined user. Beautiful! This works on my test environment.
Now on to the production scenario.

Server 2012 R2:
I have done everything as in my test scenario, but alas, I am once again at the point where the service stops (when I try to start it) and gives an error of "a device attached to the system is not functioning"
Now, the accounts I am using to define all of this is a domain account as part of the Domain Administrators group.
In all of the steps, it has accepted my domain credentials - in the powershell commands and in the log on properties of my service in services.msc.

Take a look at my autostart.properties file"
#file starts
# Default policy is to deny starting a VM, the other option is "allow".
default_policy = deny

# Bob is allowed to start virtual machines but starting them
# will be delayed for 10 seconds
mnr@GXC.local = {
allow = true
startup_delay = 10
}
#file ends

Any ideas?
Post Reply