Convenient way to enable/disable Hyper-V in Windows 8

I really like the Hyper-V support in Windows 8, however, there are some situations in which I need to disable Hyper-V in order to run some apps which don't like to be executed even in the root partition of the virtualized environment.
What I've been currently doing is disabling the feature completely from the "Add or remove windows features" dialog and restarting, enabling it again when needed.
I would like to know if there's any better way to do this that comes to mind, it could even be a shortcut that i could double-click and will actually add or remove the feature for me and restart (I guess this may be possible with a PowerShell script).


Solution 1:

Disclaimer: I haven't done this for removing a feature, AND as a final caveat there's probably going to be a slew of Windows Update updates to install every time you enable it again.

Having said that, from an elevated command prompt:

dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

and

dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

Here's what running the enable command looks like on my PC, which already has Hyper-V enabled and running:

>dism /Online /enable-feature:Microsoft-Hyper-V /All

Deployment Image Servicing and Management tool Version: 6.2.9200.16384

Image Version: 6.2.9200.16384

Enabling feature(s) [==========================100.0%==========================] The operation completed successfully.

When enabling the feature since it's Hyper-V it might ask you to reboot and run the command again. That seems vaguely familiar. You could wind up having to reboot twice, in other words. But maybe it won't do it to you since that machine already had Hyper-V enabled before.

Solution 2:

This is an old answer but for the sake of completeness and because I knew there was a better way than the top result.

You should run both commands from an elevated command prompt.

To disable hypervisor:

bcdedit /set hypervisorlaunchtype off

To reenable hypervisor (changing it to default value):

bcdedit /set hypervisorlaunchtype auto

Of course it still requires restart.