Skip to content

Instantly share code, notes, and snippets.

@SakiiR
Created July 21, 2022 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SakiiR/7c9a9420adf71e807ef4cfb9d4296da3 to your computer and use it in GitHub Desktop.
Save SakiiR/7c9a9420adf71e807ef4cfb9d4296da3 to your computer and use it in GitHub Desktop.
HyperV toggle - Faceit =)
@echo off
echo Virtualization must be disabled to use anti-cheat clients like FACEIT and ESEA
echo.
net session >nul 2>&1
if %ERRORLEVEL% EQU 0 goto :chchchchoices
echo This script requires elevated privileges. Re-run as Administrator to continue
goto :exit
:chchchchoices
echo.
echo Press 1 to ENABLE virtualization
echo Press 2 to DISABLE virtualization
echo Press 3 to ENABLE Windows Subsystem for Linux (WSL)
echo Press 4 to ENABLE WSL 2
echo Press 9 to exit
choice /C 12349
if %ERRORLEVEL% EQU 1 goto :enablevirt
if %ERRORLEVEL% EQU 2 goto :disablevirt
if %ERRORLEVEL% EQU 3 goto :enablewsl
if %ERRORLEVEL% EQU 4 goto :enablewsl2
if %ERRORLEVEL% EQU 5 goto :exit
:enablevirt
bcdedit /set hypervisorlaunchtype auto
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v "Enabled" /t REG_DWORD /d 1 /f
echo.
echo Virtualization has been enabled. Restart for changes to take effect.
goto :chchchchoices
:disablevirt
bcdedit /set hypervisorlaunchtype off
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v "Enabled" /t REG_DWORD /d 0 /f
echo.
echo Virtualization has been disabled. Restart for changes to take effect.
goto :restart
:enablewsl
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
echo.
echo Windows Subsystem for Linux version 1 has been installed. To update to version 2, a restart is required.
goto :restart
:enablewsl2
wsl --set-default-version 2
echo.
if %ERRORLEVEL% EQU 0 (echo WSL2 is now the default version) else (echo "Something went wrong")
goto :chchchchoices
:restart
echo.
echo Restart now?
choice /C YN
if %ERRORLEVEL% EQU 1 goto :restartmeow
if %ERRORLEVEL% EQU 2 goto :exit
:restartmeow
shutdown /r /t 0
:exit
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment