开发人员技术 | 通用 Windows 平台 (UWP)
用于构建和发布适用于 Windows 设备的应用的Microsoft平台。
我在使用VirtualBox时发现无法调用Hyper-V(显示龟速模式,Execution Engine:native API),使用以下ps1代码发现Hyper-V已被占用:
# 检查 Hyper-V/Hypervisor 占用情况
Write-Host "=== Hypervisor 检测脚本 ===`n"
# Step 1: 检查 systeminfo
Write-Host "[1] 检查 systeminfo..."
$sysinfo = systeminfo | findstr /i "Hyper-V"
if ($sysinfo -match "已检测到虚拟机监控程序") {
Write-Host "⚠ 已检测到 hypervisor (可能占用了 VT-x/AMD-V)"
} else {
Write-Host "✅ 未检测到 hypervisor,可以被 VirtualBox 使用"
}
Write-Host $sysinfo "`n"
# Step 2: 检查 bcdedit 配置
Write-Host "[2] 检查 bcdedit..."
$bcd = bcdedit /enum {current}
$hvsetting = $bcd | findstr hypervisorlaunchtype
if ($hvsetting) {
Write-Host "bcdedit 配置: $hvsetting"
} else {
Write-Host "bcdedit 配置: 未显式设置 (默认=Auto)"
}
Write-Host ""
# Step 3: 检查常见占用进程
Write-Host "[3] 检查常见占用虚拟化的进程..."
$procs = "vmmem","vmmemWSL","qemu-system-x86_64","Bluestacks","LdVBoxHeadless","NemuHeadless"
foreach ($p in $procs) {
$running = Get-Process -Name $p -ErrorAction SilentlyContinue
if ($running) {
Write-Host "⚠ 检测到进程: $p (可能占用虚拟化)"
}
}
Write-Host "进程检查完成。`n"
# Step 4: 建议动作
Write-Host "[4] 建议动作:"
if ($sysinfo -match "已检测到虚拟机监控程序") {
Write-Host "👉 建议运行: bcdedit /set hypervisorlaunchtype off"
Write-Host " 然后重启电脑,再次运行本脚本确认。"
} else {
Write-Host "✅ 系统没有加载 hypervisor,可以直接运行 VirtualBox。"
}
输出如下:
我尝试过运行bcdedit的指令。
然后我尝试在Windows功能中关闭Hyper-V相关的功能后重启还是不行,于是我使用以下代码再次下载HpyerV并重新关闭依旧不能让VB摆脱龟速模式:
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
我该怎么做才能关闭Hyper-V?