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).
- 1,021
8 Answers
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.
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.
- 2,880
You could create two boot entries so you could choose to decide to boot OS system with or without Hyper-V.
- Type the following in the command prompt:
bcdedit /copy {default} /d "No Hypervisor"
- It says:
"The entry was successfully copied to {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}."
- Then type the following command:
bcdedit /set {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} hypervisorlaunchtype off
- 58,727
- 279
- Hit the Windows Key and type “windows features”
- Hit the Windows Key + W combo to bring up the Windows Settings panel of the Start Screen.
- Click on Turn Windows features on or off
- When the Turn Windows features on or off dialog appears, look for Hyper-V and deselect it
- Click OK
- Restart your computer when prompted
- Install VMware Workstation
- Enable Hyper-V again through the Turn Windows features on or off dialog
- Restart your computer
For Windows 10:
- Press Windows key
- Type "Turn Windows features on or off"
- Deselect checkbox next to Hyper-V
- Select OK
- Select Restart now
- 89
You can use Hyper-V Switch that basically employs the bcdedit method already described here but puts a simple one-click GUI over it. It shows you the current configuration state and lets you enable or disable Hyper-V and reboots the computer, too. I’ve made this little tool and it works on my Windows 10 computer.
- 2,480
- 8
- 29
- 46
Powershell is also possible, using DISM wrapped as PS cmdlets, and one can read the settings first before doing the change.
//Test
PS> Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
//Turn off
PS> Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
//Turn on
PS> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All
Refs
- Powershell saw in this 2014-03 post which summarizes all options, http://www.eightforums.com/tutorials/42041-hyper-v-enable-disable-windows-8-a.html; MS Doc tell about the Get-WindowsOptionalFeature option, http://technet.microsoft.com/en-us/library/hh852173.aspx
- The Boot Entry Config Data edit (BECD) can also Read (/export) settings, per http://technet.microsoft.com/en-us/library/cc709667%28v=ws.10%29.aspx and other Doc http://msdn.microsoft.com/en-us/library/windows/hardware/ff542202%28v=vs.85%29.aspx
- 103
- 405
I made a PowerShell script to help enable/disable Hyper-V. This checks the state so you don't reboot if you are already in the desired state:
param([string]$state='Off')
'Set Hyper-V ' + $state
$lines = bcdedit
ForEach($line in $lines) {
$pos = $line.IndexOf(' ')
If($pos -gt 0) {
$prompt = $line.Substring(0, $pos)
$curstate = $line.Substring($pos).Trim()
If($prompt -eq 'hypervisorlaunchtype') {
'[' + $prompt + '] = [' + $curstate + ']'
If($curstate -ne $state) {
'Setting hypervisorlauchtype to ' + $state
$result = bcdedit /set hypervisorlaunchtype $state
'Result = [' + $result + ']'
If($result -eq 'The operation completed successfully.') {
'Restarting in two seconds'
Start-Sleep -s 2
Restart-Computer
} Else {
'Error setting state'
Start-Sleep -s 5
}
} Else {
'Hypervisor launch type is already ' + $state
Start-Sleep -s 5
}
}
}
}
Then create two shortcuts on your desktop "Hyper-V Off" Target:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\Scripts\SetHyper-V.ps1 -state Off
and "Hyper-V On" Target:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\Scripts\SetHyper-V.ps1 -state Auto`
- 11
- From windows console (cmd) with Admin rights:
Cleanup & house-keeping the Windows Component Store (WinSxS)
Dism /Online /Cleanup-Image /RestoreHealth Dism.exe /online /Cleanup-Image /StartComponentCleanup
Analyzes system files and restores if necessary
sfc /scannow
(According to https://ugetfix.com/ask/how-to-disable-hyper-v-in-windows-10/ )
- Turn off hypervisor auto-start at boot configuration
bcdedit /set {current} hypervisorlaunchtype off
(Source: https://blogs.technet.microsoft.com/gmarchetti/2008/12/07/turning-hyper-v-on-and-off/)
- Windows PowerShell (with administrative privileges):
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
(Sources: https://ugetfix.com/ask/how-to-disable-hyper-v-in-windows-10/ and https://support.microsoft.com/en-us/help/3204980/virtualization-applications-do-not-work-together-with-hyper-v-device-g)
- Turn Windows Features On or off -> Hyper-V all unticked
- This PC, Properties, Device Manager, System Devices and remove Hyper-V there as well.
For completeness, certain Virtualization issues are related to the Device Guard and Credential Guard security features:
mmc.exe, add snap-in Local Computer Policy Under Computer Configuration / Administrative Templates / System / Device Guard / Turn On Virtualization Based Security
Core isolation in Settings / Update & Security / Windows Security / Device Security / Core isolation
https://www.tenforums.com/tutorials/68913-enable-disable-device-guard-windows-10-a.html ; https://blogs.technet.microsoft.com/ash/2016/03/02/windows-10-device-guard-and-credential-guard-demystified/
https://weblogs.asp.net/dixin/run-hyper-v-and-vmware-virtual-machines-on-windows-10