SUNNY (@sunny43) 在 分享一个解决 wsl 0x80070569 错误的办法 中发帖
在 .bashrc 或 .zshrc 中添加下面的脚本:
check_vmcompute() {
local vmcompute_status=$(powershell.exe -NoProfile -Command "(Get-Service vmcompute).Status" 2>/dev/null | tr -d '\r')
if [[ "$vmcompute_status" != "Running" ]]; then
echo "vmcompute 未运行,正在重启..."
powershell.exe -NoProfile -Command "Start-Service vmcompute" 2>/dev/null
fi
}
check_vmcompute
之后每次启动 shell 都会检查并重启 Hyper-V 服务...