I have WINDOWS10 and win running in VB.
I need before WINDOWS10 restarts, it turns off VB.
I've just created a file bat with this script inside, and it works
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm win poweroff
The problem is how to run it and where. I tried in Local Group Policy Editor, but it doesn't work.
Surely I made some mistake.
Can someone help me?
Thanks.
Turning off VB
-
- Site Moderator
- Posts: 20292
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Turning off VB
First, "poweroff" is like pulling the plug or losing power on a PC. Windows does not like pulling the plug or losing power. OS corruption will occur eventually.
"acpipowerbutton" is better: When the OS in the VM is set to respond to a power button push as instructions to shut down, the "acpipowerbutton" command will trigger the VM OS to shut down gracefully, without "poweroff"s unplug-power-loss data corruption.
Second, there is no way to get the host Windows OS to wait during shutdown until the Virtualbox process shuts down. Windows doesn't have that capability that Virtualbox can use. (Curiously, Notepad does, but the devs have said they cannot get Virtualbox to do what Notepad does; Windows doesn't allow it.) GP Editor scripts run too late for the VM to respond quickly enough, been there tried that.
Virtualbox can save-state a VM when the host hibernates, though.
The only way I have seen to get a VM to be handled correctly when the host is shut down or logged off is to run the VM as a service. I have used "VboxVMservice" viewtopic.php?t=4762 successfully before, back in 4.something days. Side effect of running a VM this way is that it will not run within the main Virtualbox window context. It will be running headless under a different account, and to see it you have to remote into the OS or the Virtualbox RDP server.
It is possible to disable enough shutdown & log-off buttons etc in the Windows interface so it is not possible to shut down the host unless the shutdown.exe command is used from a command line or batch file. You can then add a vboxmanage command to "acpipowerbutton" the VM gracefully to a batch file which checks that the VM state is powered off, then run
"shutdown -s -t 0".
"acpipowerbutton" is better: When the OS in the VM is set to respond to a power button push as instructions to shut down, the "acpipowerbutton" command will trigger the VM OS to shut down gracefully, without "poweroff"s unplug-power-loss data corruption.
Second, there is no way to get the host Windows OS to wait during shutdown until the Virtualbox process shuts down. Windows doesn't have that capability that Virtualbox can use. (Curiously, Notepad does, but the devs have said they cannot get Virtualbox to do what Notepad does; Windows doesn't allow it.) GP Editor scripts run too late for the VM to respond quickly enough, been there tried that.
Virtualbox can save-state a VM when the host hibernates, though.
The only way I have seen to get a VM to be handled correctly when the host is shut down or logged off is to run the VM as a service. I have used "VboxVMservice" viewtopic.php?t=4762 successfully before, back in 4.something days. Side effect of running a VM this way is that it will not run within the main Virtualbox window context. It will be running headless under a different account, and to see it you have to remote into the OS or the Virtualbox RDP server.
It is possible to disable enough shutdown & log-off buttons etc in the Windows interface so it is not possible to shut down the host unless the shutdown.exe command is used from a command line or batch file. You can then add a vboxmanage command to "acpipowerbutton" the VM gracefully to a batch file which checks that the VM state is powered off, then run
"shutdown -s -t 0".
-
- Posts: 12
- Joined: 15. Nov 2022, 16:47
Re: Turning off VB
Thanks for the answer. Yes I'll acpipowerbutton.
My idea is to turn off everyday by script the virtualbox at 11:00pm and restart WINDOWS10 at 11:30pm
When WINDOWS10 boots, it loads virtualbox at the startup.
All this to manage possibles Windows update daily.
What do you think about it?
My idea is to turn off everyday by script the virtualbox at 11:00pm and restart WINDOWS10 at 11:30pm
When WINDOWS10 boots, it loads virtualbox at the startup.
All this to manage possibles Windows update daily.
What do you think about it?
-
- Site Moderator
- Posts: 20292
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Turning off VB
That's an interesting concept!
Myself, I don't like Windows to run updates on my workstation until I get a chance to see if the updates blow up the internet, which does happen occasionally. Also, I want to do full host backup images first before the Windows updates, just in case.
Since you have Group Policy Editor, you can do what I do: Set GPE to not do the updates until you manually trigger them.
gpedit.msc > Local Computer Policy > Administrative Templates > Windows Components > Windows Update > Configure Automatic Updates > set "Configure automatic updating" dropdown to 2 (Notify for download and auto install) or possibly 3 (Auto download and notify for install).
Then all you'll get is popups when updates are ready. But the PC won't automatically reboot. When you get a moment for downtime, you can shut down the VMs manually, run backups, run the updates, then reboot the host and let the VMs come back up.
If you want to keep the present daily reboot, you could run the VM shutdown script each day from the Task Scheduler at the desired time. The script could then include the reboot command for the host: "shutdown -r -t 0" . If updates don't automatically run during such a reboot then there are command line methods to run updates, a web-search will show them.
Myself, I don't like Windows to run updates on my workstation until I get a chance to see if the updates blow up the internet, which does happen occasionally. Also, I want to do full host backup images first before the Windows updates, just in case.
Since you have Group Policy Editor, you can do what I do: Set GPE to not do the updates until you manually trigger them.
gpedit.msc > Local Computer Policy > Administrative Templates > Windows Components > Windows Update > Configure Automatic Updates > set "Configure automatic updating" dropdown to 2 (Notify for download and auto install) or possibly 3 (Auto download and notify for install).
Then all you'll get is popups when updates are ready. But the PC won't automatically reboot. When you get a moment for downtime, you can shut down the VMs manually, run backups, run the updates, then reboot the host and let the VMs come back up.
If you want to keep the present daily reboot, you could run the VM shutdown script each day from the Task Scheduler at the desired time. The script could then include the reboot command for the host: "shutdown -r -t 0" . If updates don't automatically run during such a reboot then there are command line methods to run updates, a web-search will show them.
-
- Volunteer
- Posts: 2558
- Joined: 30. May 2007, 18:05
- Primary OS: Fedora other
- VBox Version: PUEL
- Guest OSses: XP, Win7, Linux, OS/2
Re: Turning off VB
Why do you want to check for updates daily and reboot for that?
Normally MS provides updates only once each month on the second Tuesday.
Normally MS provides updates only once each month on the second Tuesday.
-
- Posts: 12
- Joined: 15. Nov 2022, 16:47
Re: Turning off VB
Ok, maybe everyday not but this is the problem I think can happen.
Both the machine can have update. Windows in the virtualbox can easly reboot itself and install update.
Windows10 must close virtualbox for reboot. So, I was thinking to close the VB and restart Windows10 for possible update install.
Virtualbox will start again after Windows 10 finish the boot.
Good or not?
Both the machine can have update. Windows in the virtualbox can easly reboot itself and install update.
Windows10 must close virtualbox for reboot. So, I was thinking to close the VB and restart Windows10 for possible update install.
Virtualbox will start again after Windows 10 finish the boot.
Good or not?
-
- Site Moderator
- Posts: 20292
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Turning off VB
Windows automatic rebooting for updates will kill the VMs. So having them shut down beforehand is important.
See my idea above about not letting Windows auto-reboot for updates.
See my idea above about not letting Windows auto-reboot for updates.