I am running an Ubuntu VM guest OS in headless mode on a Windows 7 host. I wrote a batch script which uses VBoxManage to start or save the state of the VM based on the passed in argument. I can start the VM just fine by putting a shortcut to the script in my startup folder, but I’m having trouble getting the VM to suspend on logout.
I tried a few different methods:
VBoxManage.exe: error: Failed to create the VirtualBox object!
VBoxManage.exe: error: Code E_ACCESSDENIED (0x80070005) - General access denied error (extended info not available)
VBoxManage.exe: error: Most likely, the VirtualBox COM server is not running or failed to start.
Is there some better way to automatically suspend the state of a VM when logging off of Windows?
The contents of the batch script:
@echo off setlocal rem list of VMs to start/stop set vm_list=Ubuntu set action=%1 if not "%action%" == "start" if not "%action%" == "stop" exit /B set command="C:\Program Files\Oracle\VirtualBox\VboxManage.exe" set logfile="C:\bin\vm_log.txt" if exist %logfile% echo.>> %logfile% echo %date% %time%>> %logfile% for %%A in (%vm_list%) do ( if "%action%" == "start" ( echo Starting %%A>> %logfile% 2>&1 %command% startvm %%A --type headless >> %logfile% 2>&1 ) else if "%action%" == "stop" ( echo Suspending %%A>> %logfile% 2>&1 %command% controlvm %%A savestate >> %logfile% 2>&1 ) ) endlocal
I have the output of the commands redirected to
vm_log.txt which is how I am able to see the messages that were reported.
User contributions licensed under CC BY-SA 3.0