Go to ...

RSS Feed

War Stories: Hypervisor turned off after every cold boot


On my HP ProBook laptop, I’ve had a strange issue regardless of which Windows 10 Insider build I am running: the Hypervisor will be turned off when the laptop is powered off, which makes it impossible to run Hyper-V virtual machines following a cold boot. When the Hypervisor is enabled, it survives restarts but the next power off / cold boot will turn it off again:

I am currently running Insider build 17704, UK English W10 PRO x64. To check if this is solely an Insider Issue, I clean installed official release version 1803 on another partition for dual boot. Got the same issue.

The fix is easy but annoying: manually set hypervisorlaunchtype type to AUTO with BCDEDIT:

bcdedit /set {current} hypervisorlaunchtype auto

By annoying, I mean that it requires a restart. Hyper-V is a type 1 hypervisor, and must be started before the Windows Kernel is launched. That means that the usual “fast apply” tricks like restarting explorer.exe or signing out / back in do not work.

I usually forget that hypervisor is not running when turning my laptop on in the mornings. I press the power button, wait until I can use Windows Hello to sign in securely, make a pot of coffee and start checking the news. When I am finally ready to start my first VM, I get notified that the hypervisor is not running. I might have 20 tabs open in Edge, news streaming from my native Finland on another display, some Word or Excel docs open and so on. It is most annoying to be forced to close everything, edit boot records in an elevated Command Prompt and restart.

Yesterday I thought: “Enough is enough!” and decided I will concentrate on this issue until I have either resolved it or found an easy workaround. I couldn’t find any information about this issue, nor any solution. So, workaround it is! Plan A was to make a script file, save it to the Start-Up folder and run it at Windows login to check if the Hypervisor is off and if yes, turn it on and restart. It would have been quite an easy solution, but I wanted the check to be done earlier, at system start-up before I have signed in. Enter Plan B, a scheduled task.

The PowerShell script I made is as simple as possible. It just checks if the Hypervisor is off. If so, it will turn it on and restart the computer. I saved it in my PowerShell scripts folder as CheckHypervisor.ps1:

$Hypervisor = (Get-WMIObject –class Win32_ComputerSystem).HypervisorPresent
if ($Hypervisor.ToString() -eq 'False')
{
cmd /c 'bcdedit /set {current} hypervisorlaunchtype auto'
Restart-Computer
}

(Get-WMIObject –class Win32_ComputerSystem).HypervisorPresent returns True if hypervisor is running, False if it is off.

Creating the task in Task Scheduler was also extremely simple. First, I had to make the task run with elevated privileges:

Click to open enlarged in a new tab.

Task Trigger: At startup:

Click to open enlarged in a new tab.

Action: Start a program powershell.exe, with following arguments:

-ExecutionPolicy Bypass -File "E:\Users\Kari\OneDrive\PS-Scripts\CheckHypervisor.ps1"

And finally, unselect all boxes in the Conditions tab:

When saving the task, credentials will be requested:

Whenever I now boot my laptop, this task runs. If the Hypervisor is not running, Windows will restart before I have signed in and turn the Hypervisor on, returning to the sign-in screen once completed. The only con is that my cold boots take now about 40 seconds longer because of the forced restart. In any case, because I usually cold boot only once a day, I’d much rather incur this small delay than forget that the Hypervisor isn’t running and then be forced to restart at more or less inconvenient times to be able to run a VM.

That´s it, I am satisfied! If this works for me, it will work for you, too.

Kari

Author: Kari Finn

A former Windows Insider MVP, Kari started in computing in the mid 80’s writing code for VAX / VMS systems. Since then, he’s worked in a variety of IT positions. He specializes in Windows image capture, customization, repair and deployment as well as Hyper-V virtualization. Kari is a proud Team Member at number #1 Windows site TenForums.com.

Leave a Reply