@echo off
title Ultimate Hyper-V disabler
color 4f

echo ========================================================
echo   CHECKING FOR ADMINISTRATOR RIGHTS...
echo ========================================================

fsutil dirty query %systemdrive% >nul
if %errorLevel% == 0 (
    echo [OK] Administrator rights confirmed.
) else (
    echo [ERROR] Please right-click and select "Run as Administrator"!
    pause
    exit
)

echo.
echo ========================================================
echo   STEP 1: FINDING BCDEDIT PATH
echo ========================================================

:: Solves the "Command not found" issue dynamically
if exist "%SystemRoot%\Sysnative\bcdedit.exe" (
    set "BCD_PATH=%SystemRoot%\Sysnative\bcdedit.exe"
) else (
    set "BCD_PATH=%SystemRoot%\System32\bcdedit.exe"
)
echo Using path: %BCD_PATH%

echo.
echo ========================================================
echo   STEP 2: DISABLING DISM COMPONENTS
echo ========================================================

dism /Online /Disable-Feature:Microsoft-Hyper-V-All /NoRestart
dism /Online /Disable-Feature:VirtualMachinePlatform /NoRestart
dism /Online /Disable-Feature:HypervisorPlatform /NoRestart

echo.
echo ========================================================
echo   STEP 3: DISABLING HYPERVISOR IN BCD
echo ========================================================

"%BCD_PATH%" /set hypervisorlaunchtype off

echo.
echo ========================================================
echo   STEP 4: SETTING REGISTRY KEYS
echo ========================================================

reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard" /v EnableVirtualizationBasedSecurity /t REG_DWORD /d 0 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard" /v RequirePlatformSecurityFeatures /t REG_DWORD /d 0 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" /v LsaCfgFlags /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" /v EnableVirtualizationBasedSecurity /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" /v RequirePlatformSecurityFeatures /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\System" /v EnableHVCI /t REG_DWORD /d 0 /f

echo.
echo ========================================================
echo   STEP 5: DELETING SYSTEM FILES (Hardcore Fix)
echo ========================================================
echo Translating PowerShell commands to CMD logic...

:: Take ownership
takeown /F "C:\Windows\System32\hvix64.exe"
takeown /F "C:\Windows\System32\hvax64.exe"

:: Grant permissions (Using universal Admin SID so it works on any language)
icacls "C:\Windows\System32\hvix64.exe" /grant *S-1-5-32-544:F /T /C
icacls "C:\Windows\System32\hvax64.exe" /grant *S-1-5-32-544:F /T /C

:: Delete (Suppress errors if file is already gone)
del /F /Q "C:\Windows\System32\hvix64.exe" 2>nul
del /F /Q "C:\Windows\System32\hvax64.exe" 2>nul

if not exist "C:\Windows\System32\hvix64.exe" echo [OK] hvix64.exe successfully removed.
if not exist "C:\Windows\System32\hvax64.exe" echo [OK] hvax64.exe successfully removed.

echo.
echo ========================================================
echo   DONE
echo ========================================================
echo Please restart your PC now.
pause