@ECHO OFF
SETLOCAL

:: Driver path
SET "DRIVER_PATH=%SystemRoot%\System32\VRFCAT-Plugins\FrameViewKM_x64.sys"

:: Check if FrameView Tool is installed
reg query "HKLM\SOFTWARE\NVIDIA Corporation\FrameView" >nul 2>&1
IF %ERRORLEVEL% EQU 0 GOTO END

:: Check if FrameView Tool (32-bit) is installed
reg query "HKLM\SOFTWARE\WOW6432Node\NVIDIA Corporation\FrameView" >nul 2>&1
IF %ERRORLEVEL% EQU 0 GOTO END

:: If FrameView Tool is NOT installed, we are the last ones.
:: Delete ONLY the driver file.

ECHO Deleting FrameView Driver...

:: Stop service just in case
sc stop FvKMDSvc >nul 2>&1
timeout /t 2 /nobreak >nul

:: Delete file
IF EXIST "%DRIVER_PATH%" (
    del /f /q "%DRIVER_PATH%"
)

:END
ENDLOCAL
EXIT /B 0