Autostart with Windows

最後更新: 2024-07-11

前言

vbox ver. 7 在 Win10 上 autostart

 


Autostart policy config file

 

To enable autostarting for a particular user (Run by administrator)

# 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
user1 = {
    allow = true
    startup_delay = 10
}

 * there must be an empty newline at the end of the file. !!!
   否則 start service 時會有 error
   "A device attached to the system is not functioning."

 * File Permission: everyone readonly

# tells the autostart services which configuration file is used

System Environment Variable: VBOXAUTOSTART_CONFIG

Value: c:\vbox_autostart_policy.conf

Checking: echo %VBOXAUTOSTART_CONFIG%

 


Window Security Policies

 

在 "Log on as as service" 加入要行 vbox 的 user a/c

gpedit.msc > Computer Configuration > Windows Settings > Security Settings >
 Local Policies > User Rights Assignment > Log on as as service

Notes

必須設定, 否則執行 "VBoxAutostartSvc install --user=<user>" 會有 Error

Error: LsaOpenPolicy failed rc=VERR_ACCESS_DENIED (0x5)
Error: Failed to get/update "logon as service" policy for user host1\user1 (VERR_ACCESS_DENIED)

 


建立 AutostartSvc

 

cd C:\Program Files\Oracle\VirtualBox

VBoxAutostartSvc install --user=<user> [--password-file=<password_file>

 * Due to Windows security policies, the autostart service cannot be installed for users with empty passwords.

e.g.

VBoxAutostartSvc install --user=user1

Successfully created the VBoxAutostartSvchost1user service.

Notes

VBoxAutostartSvc delete --user=user

 


設定 VM autostart

 

VBoxManage list vms

VBoxManage modifyvm VM_NAME --autostart-enabled on

VBoxManage.exe showvminfo vpn | findstr Auto

 


人手 start service

 

Syntax

net start VBoxAutostartSvc[HOSTNAME][USERNAME]

e.g.

net start VBoxAutostartSvchost1user1

 


連上 Console

 

 * 必須要係同一個 user A/C 才 connect 到


 

Creative Commons license icon Creative Commons license icon