如何在命令行中禁用 Hyper-V?
How to disable Hyper-V in command line?
我正在尝试打开 VMware,它说 VMware 播放器和 Hyper-V 不兼容。我找到了它 here,但它无法使用它提供的命令。
我试图查看帮助,发现那里有 /hypervisorsettings
选项。但仍然无法使用它,它说 The parameter is incorrect
。
有人可以帮忙吗?
在提升的命令提示符中写下:
要禁用:
bcdedit /set hypervisorlaunchtype off
启用:
bcdedit /set hypervisorlaunchtype auto
(来自评论-重启生效)
这个命令有效
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
运行 然后同意在出现提示时重新启动计算机。
我 运行 它在 Windows 10 上的提升权限 PowerShell 中,但它也应该适用于 Win 8 或 7。
命令行:
dism /online /disable-feature /featurename:microsoft-hyper-v-all
如果有人得到:
We couldn’t complete the updates, Undoing changes
尝试禁用 Hyper-V 后,尝试从设备管理器->网络适配器中卸载 Hyper-V 虚拟网络适配器
您可以在管理员提示符下使用和不使用 Hyper-V 进行 Windows 10 配置,如下所示:
bcdedit /copy {current} /d "Windows 10 no Hyper-V"
找到刚创建的 "Windows 10 no Hyper-V" bootentry 的新 id,例如。
{094a0b01-3350-11e7-99e1-bc5ec82bc470}
bcdedit /set {094a0b01-3350-11e7-99e1-bc5ec82bc470} hypervisorlaunchtype Off
重新启动后,您可以选择 Windows 10 在启动时使用或不使用 Hyper-V
你可以使用我的脚本。
将代码行粘贴到记事本并另存为 vbs(例如 switch_hypervisor.vbs)
Option Explicit
Dim backupfile
Dim record
Dim myshell
Dim appmyshell
Dim myresult
Dim myline
Dim makeactive
Dim makepassive
Dim reboot
record=""
Set myshell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.Length = 0 Then
Set appmyshell = CreateObject("Shell.Application")
appmyshell.ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1
WScript.Quit
End if
Set backupfile = CreateObject("Scripting.FileSystemObject")
If Not (backupfile.FileExists("C:\bcdedit.bak")) Then
Set myresult = myshell.Exec("cmd /c bcdedit /export c:\bcdedit.bak")
End If
Set myresult = myshell.Exec("cmd /c bcdedit")
Do While Not myresult.StdOut.AtEndOfStream
myline = myresult.StdOut.ReadLine()
If myline="The boot configuration data store could not be opened." Then
record=""
exit do
End If
If Instr(myline, "identifier") > 0 Then
record=""
If Instr(myline, "{current}") > 0 Then
record="current"
End If
End If
If Instr(myline, "hypervisorlaunchtype") > 0 And record = "current" Then
If Instr(myline, "Auto") > 0 Then
record="1"
Exit Do
End If
If Instr(myline, "On") > 0 Then
record="1"
Exit Do
End If
If Instr(myline, "Off") > 0 Then
record="0"
Exit Do
End If
End If
Loop
If record="1" Then
makepassive = MsgBox ("Hypervisor status is active, do you want set to passive? ", vbYesNo, "Hypervisor")
Select Case makepassive
Case vbYes
myshell.run "cmd.exe /C bcdedit /set hypervisorlaunchtype off"
reboot = MsgBox ("Hypervisor chenged to passive; Computer must reboot. Reboot now? ", vbYesNo, "Hypervisor")
Select Case reboot
Case vbYes
myshell.run "cmd.exe /C shutdown /r /t 0"
End Select
Case vbNo
MsgBox("Not Changed")
End Select
End If
If record="0" Then
makeactive = MsgBox ("Hypervisor status is passive, do you want set active? ", vbYesNo, "Hypervisor")
Select Case makeactive
Case vbYes
myshell.run "cmd.exe /C bcdedit /set hypervisorlaunchtype auto"
reboot = MsgBox ("Hypervisor changed to active; Computer must reboot. Reboot now?", vbYesNo, "Hypervisor")
Select Case reboot
Case vbYes
myshell.run "cmd.exe /C shutdown /r /t 0"
End Select
Case vbNo
MsgBox("Not Changed")
End Select
End If
If record="" Then
MsgBox("Error: record can't find")
End If
以管理员身份打开命令提示符并运行此命令:
bcdedit /set {current} hypervisorlaunchtype off
重启后,Hyper-V 仍然安装,但 Hypervisor 不再 运行ning。现在您可以毫无问题地使用 VMware。
如果您再次需要 Hyper-V,请以管理员身份打开命令提示符并运行此命令:
bcdedit /set {current} hypervisorlaunchtype auto
以管理员身份打开命令提示符并写入:
bcdedit /set hypervisorlaunchtype off
OP 对我来说是最好的答案,而且其他人似乎也想出了 -All 添加。我设置了两个批处理文件,然后设置了它们的快捷方式,这样你就可以设置 运行 作为管理员权限,简单易行。
批量关闭
Call dism.exe /Online /Disable-Feature:Microsoft-Hyper-V-All
批量开启
Call dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
右击->创建桌面快捷方式。
右键单击快捷方式 -> 属性 -> 快捷方式选项卡下 -> 高级 -> 运行 as admin
我尝试了所有的堆栈溢出方法,但都没有用。但这对我有用:
- 打开系统配置
- 单击“服务”选项卡
- 取消选中所有 Hyper-V 个相关
这不是对 OP 问题的直接回答,但如果您尝试了所有命令并且 Hyper-V 显示为已禁用,但仍然无法启动虚拟化软件像 VirtualBox 或 VMWare,碰巧你在你的机器上启用了 WSL2
以下解决方案可能适合您。
前往 Control Panel
> Programs & Features
> Turn Windows Feature On/OFF
重点来了,下面三个都应该是disabled/unchecked。
- 虚拟机平台
- Windows 管理程序平台
- Windows Linux
的子系统
重启!
我在 https://www.interfacett.com/blogs/enabling-hypervisor-auto-start-boot-configuration-database-bcd/
上找到了完美的解决方案
它无法使用给定的命令。但是,当您转到 Power Shell 并使用命令 CMD 然后输入 on 或 off 时
bcdedit /set {current} hypervisorlaunchtype [关闭或打开选择任何]
然后它没有任何问题。
我正在尝试打开 VMware,它说 VMware 播放器和 Hyper-V 不兼容。我找到了它 here,但它无法使用它提供的命令。
我试图查看帮助,发现那里有 /hypervisorsettings
选项。但仍然无法使用它,它说 The parameter is incorrect
。
有人可以帮忙吗?
在提升的命令提示符中写下:
要禁用:
bcdedit /set hypervisorlaunchtype off
启用:
bcdedit /set hypervisorlaunchtype auto
(来自评论-重启生效)
这个命令有效
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
运行 然后同意在出现提示时重新启动计算机。
我 运行 它在 Windows 10 上的提升权限 PowerShell 中,但它也应该适用于 Win 8 或 7。
命令行:
dism /online /disable-feature /featurename:microsoft-hyper-v-all
如果有人得到:
We couldn’t complete the updates, Undoing changes
尝试禁用 Hyper-V 后,尝试从设备管理器->网络适配器中卸载 Hyper-V 虚拟网络适配器
您可以在管理员提示符下使用和不使用 Hyper-V 进行 Windows 10 配置,如下所示:
bcdedit /copy {current} /d "Windows 10 no Hyper-V"
找到刚创建的 "Windows 10 no Hyper-V" bootentry 的新 id,例如。 {094a0b01-3350-11e7-99e1-bc5ec82bc470}
bcdedit /set {094a0b01-3350-11e7-99e1-bc5ec82bc470} hypervisorlaunchtype Off
重新启动后,您可以选择 Windows 10 在启动时使用或不使用 Hyper-V
你可以使用我的脚本。 将代码行粘贴到记事本并另存为 vbs(例如 switch_hypervisor.vbs)
Option Explicit
Dim backupfile
Dim record
Dim myshell
Dim appmyshell
Dim myresult
Dim myline
Dim makeactive
Dim makepassive
Dim reboot
record=""
Set myshell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.Length = 0 Then
Set appmyshell = CreateObject("Shell.Application")
appmyshell.ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1
WScript.Quit
End if
Set backupfile = CreateObject("Scripting.FileSystemObject")
If Not (backupfile.FileExists("C:\bcdedit.bak")) Then
Set myresult = myshell.Exec("cmd /c bcdedit /export c:\bcdedit.bak")
End If
Set myresult = myshell.Exec("cmd /c bcdedit")
Do While Not myresult.StdOut.AtEndOfStream
myline = myresult.StdOut.ReadLine()
If myline="The boot configuration data store could not be opened." Then
record=""
exit do
End If
If Instr(myline, "identifier") > 0 Then
record=""
If Instr(myline, "{current}") > 0 Then
record="current"
End If
End If
If Instr(myline, "hypervisorlaunchtype") > 0 And record = "current" Then
If Instr(myline, "Auto") > 0 Then
record="1"
Exit Do
End If
If Instr(myline, "On") > 0 Then
record="1"
Exit Do
End If
If Instr(myline, "Off") > 0 Then
record="0"
Exit Do
End If
End If
Loop
If record="1" Then
makepassive = MsgBox ("Hypervisor status is active, do you want set to passive? ", vbYesNo, "Hypervisor")
Select Case makepassive
Case vbYes
myshell.run "cmd.exe /C bcdedit /set hypervisorlaunchtype off"
reboot = MsgBox ("Hypervisor chenged to passive; Computer must reboot. Reboot now? ", vbYesNo, "Hypervisor")
Select Case reboot
Case vbYes
myshell.run "cmd.exe /C shutdown /r /t 0"
End Select
Case vbNo
MsgBox("Not Changed")
End Select
End If
If record="0" Then
makeactive = MsgBox ("Hypervisor status is passive, do you want set active? ", vbYesNo, "Hypervisor")
Select Case makeactive
Case vbYes
myshell.run "cmd.exe /C bcdedit /set hypervisorlaunchtype auto"
reboot = MsgBox ("Hypervisor changed to active; Computer must reboot. Reboot now?", vbYesNo, "Hypervisor")
Select Case reboot
Case vbYes
myshell.run "cmd.exe /C shutdown /r /t 0"
End Select
Case vbNo
MsgBox("Not Changed")
End Select
End If
If record="" Then
MsgBox("Error: record can't find")
End If
以管理员身份打开命令提示符并运行此命令:
bcdedit /set {current} hypervisorlaunchtype off
重启后,Hyper-V 仍然安装,但 Hypervisor 不再 运行ning。现在您可以毫无问题地使用 VMware。
如果您再次需要 Hyper-V,请以管理员身份打开命令提示符并运行此命令:
bcdedit /set {current} hypervisorlaunchtype auto
以管理员身份打开命令提示符并写入:
bcdedit /set hypervisorlaunchtype off
OP 对我来说是最好的答案,而且其他人似乎也想出了 -All 添加。我设置了两个批处理文件,然后设置了它们的快捷方式,这样你就可以设置 运行 作为管理员权限,简单易行。
批量关闭
Call dism.exe /Online /Disable-Feature:Microsoft-Hyper-V-All
批量开启
Call dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
右击->创建桌面快捷方式。 右键单击快捷方式 -> 属性 -> 快捷方式选项卡下 -> 高级 -> 运行 as admin
我尝试了所有的堆栈溢出方法,但都没有用。但这对我有用:
- 打开系统配置
- 单击“服务”选项卡
- 取消选中所有 Hyper-V 个相关
这不是对 OP 问题的直接回答,但如果您尝试了所有命令并且 Hyper-V 显示为已禁用,但仍然无法启动虚拟化软件像 VirtualBox 或 VMWare,碰巧你在你的机器上启用了 WSL2
以下解决方案可能适合您。
前往 Control Panel
> Programs & Features
> Turn Windows Feature On/OFF
重点来了,下面三个都应该是disabled/unchecked。
- 虚拟机平台
- Windows 管理程序平台
- Windows Linux 的子系统
重启!
我在 https://www.interfacett.com/blogs/enabling-hypervisor-auto-start-boot-configuration-database-bcd/
上找到了完美的解决方案它无法使用给定的命令。但是,当您转到 Power Shell 并使用命令 CMD 然后输入 on 或 off 时 bcdedit /set {current} hypervisorlaunchtype [关闭或打开选择任何] 然后它没有任何问题。