如果您的计算机最近更改涉及 Hyper-V,可能会遇到此问题,您需要在使用 VMWare 或 VirtualBox 时禁用它。他们不一起工作。 Windows Sandbox 和 WSL 2 需要 Hyper-V 管理程序,这目前破坏了 VMWare。基本上,您需要在下次重启时运行以下命令来启用/禁用 Hyper-V 服务。
要禁用 Hyper-V 并让 VMWare 正常工作,请以管理员身份在 PowerShell 中:
bcdedit /set hypervisorlaunchtype off
要暂时重新启用 Hyper-V 并破坏 VMWare,请以管理员身份在 PowerShell 中:
bcdedit /set hypervisorlaunchtype auto
之后您需要重新启动。我编写了一个 PowerShell 脚本,它将为您切换并通过对话框确认它。它甚至可以使用this technique 自我提升为管理员,因此您只需右键单击并运行脚本即可快速更改您的 Hyper-V 模式。它也可以很容易地修改为为您重新启动,但我个人不希望这种情况发生。将此保存为 hypervisor.ps1 并确保您已运行 Set-ExecutionPolicy RemoteSigned 以便您可以运行 PowerShell 脚本。
# Get the ID and security principal of the current user account
$myWindowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent();
$myWindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($myWindowsID);
# Get the security principal for the administrator role
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator;
# Check to see if we are currently running as an administrator
if ($myWindowsPrincipal.IsInRole($adminRole))
{
# We are running as an administrator, so change the title and background colour to indicate this
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)";
$Host.UI.RawUI.BackgroundColor = "DarkBlue";
Clear-Host;
}
else {
# We are not running as an administrator, so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter with added scope and support for scripts with spaces in it's path
$newProcess.Arguments = "-windowstyle hidden & '" + $script:MyInvocation.MyCommand.Path + "'"
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit;
}
Add-Type -AssemblyName System.Windows.Forms
$state = bcdedit /enum | Select-String -Pattern 'hypervisorlaunchtype\s*(\w+)\s*'
if ($state.matches.groups[1].ToString() -eq "Off"){
$UserResponse= [System.Windows.Forms.MessageBox]::Show("Enable Hyper-V?" , "Hypervisor" , 4)
if ($UserResponse -eq "YES" )
{
bcdedit /set hypervisorlaunchtype auto
[System.Windows.Forms.MessageBox]::Show("Enabled Hyper-V. Reboot to apply." , "Hypervisor")
}
else
{
[System.Windows.Forms.MessageBox]::Show("No change was made." , "Hypervisor")
exit
}
} else {
$UserResponse= [System.Windows.Forms.MessageBox]::Show("Disable Hyper-V?" , "Hypervisor" , 4)
if ($UserResponse -eq "YES" )
{
bcdedit /set hypervisorlaunchtype off
[System.Windows.Forms.MessageBox]::Show("Disabled Hyper-V. Reboot to apply." , "Hypervisor")
}
else
{
[System.Windows.Forms.MessageBox]::Show("No change was made." , "Hypervisor")
exit
}
}