Developers often encounter the need to run virtual machines using VirtualBox and Hyper-V-based mobile emulators on the same machine (for example Windows Mobile or Visual Studio Android Emulator). Unfortunately only one of the two can be enabled at once. The easiest solution is to create two boot entries and disable Hyper-V in one of them.
CMD way
The awesomeScott Hanselman provided a quick command line solution in one of his blogposts. As part of creating a Chocolatey based PowerShell install script for my most used tools after computer reinstall, I wanted to make this automatic and preferably skip the copy-paste step.
PowerShell script
The script is very simple:
$bcdResult = ( bcdedit /copy `{current`} /d "No Hyper-V" ) | Out-String $bcdResult -match "\{.+\}" bcdedit /set $matches[0] hypervisorlaunchtype off
First line of the script runs the bcdedit tool and create a copy of the current boot entry. The result is a string in the following form:
The entry was successfully copied to {XX-XX-XXX-XXXX-XXXXXXXX}.
We need to parse out the identifier enclosed between curly brackets. This is just the job for regular expressions on the second line of the script. The matches are stored in the $matches variable. Finally we can use the identifier to modify the boot entry to disable Hyper-V on the third line. And that's it! Pretty simple but convenient. You can simply run the script and the new Hyper-V-less boot entry will be created for you automatically. Be sure to run the script with administrator permissions. You can download the script here.