Skip to content

Instantly share code, notes, and snippets.

@albertopasqualetto
Created May 20, 2022 22:42
Show Gist options
  • Save albertopasqualetto/257bd83fe47b8c11e4ce1fa46bb82781 to your computer and use it in GitHub Desktop.
Save albertopasqualetto/257bd83fe47b8c11e4ce1fa46bb82781 to your computer and use it in GitHub Desktop.
bcdEdit auto switch hypervisor
@echo off
:: Source: https://stackoverflow.com/questions/1894967/how-to-request-administrator-access-inside-a-batch-file
:: Source: https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights
:: batch code to request admin previleges, if no admin previleges
fltmc >nul 2>&1
if NOT %errorLevel% == 0 (
powershell start -verb runas '%0' am_admin & exit /b
)
bcdedit | findstr /c:"hypervisorlaunchtype Auto" >nul 2>&1
if errorlevel == 1 (
echo Set hypervisorlaunchtype to auto (Use WSL2^)
pause
bcdedit /set hypervisorlaunchtype auto
) else (
echo Set hypervisorlaunchtype to off (Use VMWare^)
pause
bcdedit /set hypervisorlaunchtype off
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment