新建脚本switch-hyperv.bat,输入以下内容,然后运行。最后重启电脑。
@echo off
"%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\SYSTEM" >nul 2>nul
if %errorlevel%==0 goto :start
echo Please use administrator account to run.
echo 请以管理员身份运行。
pause
goto :end
:start
pushd "%~dp0"
:menu
echo MENU
echo 1. Set current boot item: hypervisorlaunchtype Auto
echo 2. Set current boot item: hypervisorlaunchtype Off
echo Q. Exit
echo.
echo Current status:
bcdedit /enum {current}|findstr hypervisorlaunchtype
echo.
set /p input=Please input:
if "%input%"=="1" goto :auto
if "%input%"=="2" goto :off
if /i "%input%"=="q" goto :end
echo.
goto :menu
:auto
bcdedit /set {current} hypervisorlaunchtype auto
goto :menu
:off
bcdedit /set {current} hypervisorlaunchtype off
goto :menu
:end
popd