windows 如何在命令行中禁用 Hyper-V?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30496116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:05:42  来源:igfitidea点击:

How to disable Hyper-V in command line?

windowscmdhypervisor

提问by Sky

I'm trying to open VMware, it says that VMware player and Hyper-V are not compatible. I found it here, but it's not working using the command it offers.

我正在尝试打开 VMware,它说 VMware 播放器和 Hyper-V 不兼容。我在这里找到了它,但是使用它提供的命令无法正常工作。

I tried to see the help, found that there's /hypervisorsettingsoption there. But still not work with it, it says The parameter is incorrect.

我试图查看帮助,发现那里有/hypervisorsettings选项。但仍然无法使用它,它说The parameter is incorrect

Can anyone help with this?

有人能帮忙吗?

回答by LukeSkCzEnDeRuPl

In an elevatedCommand Prompt write this :

提升的命令提示符中写下这个:

To disable:

要禁用:

bcdedit /set hypervisorlaunchtype off

To enable:

启用:

bcdedit /set hypervisorlaunchtype auto 

(From comments - restart to take effect)

(来自评论——重启生效)

回答by DivineOps

This command works

此命令有效

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All

Run it then agree to restart the computer when prompted.

运行它,然后在出现提示时同意重新启动计算机。

I ran it in elevated permissions PowerShell on Windows 10, but it should also work on Win 8 or 7.

我在 Windows 10 上以提升权限的 PowerShell 运行它,但它也应该适用于 Win 8 或 7。

回答by hfmanson

You can have a Windows 10 configuration with and without Hyper-V as follows in an Admin prompt:

您可以在管理员提示中按如下方式使用或不使用 Hyper-V 进行 Windows 10 配置:

bcdedit /copy {current} /d "Windows 10 no Hyper-V"

find the new id of the just created "Windows 10 no Hyper-V" bootentry, eg. {094a0b01-3350-11e7-99e1-bc5ec82bc470}

找到刚刚创建的“Windows 10 no Hyper-V”引导项的新 ID,例如。{094a0b01-3350-11e7-99e1-bc5ec82bc470}

bcdedit /set {094a0b01-3350-11e7-99e1-bc5ec82bc470} hypervisorlaunchtype Off

After rebooting you can choose between Windows 10 with and without Hyper-V at startup

重新启动后,您可以在启动时选择带和不带 Hyper-V 的 Windows 10

回答by Ignas Vy?nia

Command line:

命令行:

dism /online /disable-feature /featurename:microsoft-hyper-v-all

dism /online /disable-feature /featurename:microsoft-hyper-v-all

If anyone is getting:

如果有人得到:

We couldn't complete the updates, Undoing changes

我们无法完成更新,正在撤消更改

after trying to disable the Hyper-V, try uninstalling Hyper-V virtual network adapters from your Device Manager->Network Adapters

尝试禁用 Hyper-V 后,尝试从设备管理器->网络适配器卸载 Hyper-V 虚拟网络适配器

回答by Iasmini Gomes

Open a command prompt as admin and run this command:

以管理员身份打开命令提示符并运行以下命令:

bcdedit /set {current} hypervisorlaunchtype off

After a reboot, Hyper-V is still installed but the Hypervisor is no longer running. Now you can use VMware without any issues.

重新启动后,Hyper-V 仍然安装,但 Hypervisor 不再运行。现在您可以毫无问题地使用 VMware。

If you need Hyper-V again, open a command prompt as admin and run this command:

如果您再次需要 Hyper-V,请以管理员身份打开命令提示符并运行以下命令:

bcdedit /set {current} hypervisorlaunchtype auto

回答by Fodor Codrut

Open command prompt as admin and write :

以管理员身份打开命令提示符并写入:

bcdedit /set hypervisorlaunchtype off

回答by Bob Phrapples

The OP had the best answer for me and it appears that others have figured out the -All addition as well. I set up two batch files, then shortcuts to those so you can set the Run As Admin permissions on them, easy-peasy.

OP 对我来说是最好的答案,而且其他人似乎也找到了 -All 添加项。我设置了两个批处理文件,然后设置了这些文件的快捷方式,以便您可以为它们设置以管理员身份运行的权限,这很简单。

Batch Off

批量关闭

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

Batch On

批处理

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

Right-click -> create desktop shortcut. Right-click the shortcut -> properties -> under the shortcut tab -> Advanced -> Run as admin

右键单击-> 创建桌面快捷方式。右键单击快捷方式-> 属性-> 快捷方式选项卡下-> 高级-> 以管理员身份运行

回答by teknokadim

you can use my script. paste code lines to notepad and save as vbs(for example switch_hypervisor.vbs)

你可以使用我的脚本。将代码行粘贴到记事本并另存为 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