@echo off setlocal cd /D "%~dp0" echo This script uninstalls the Beszel agent echo. call env.cmd echo Checking adminstrative rights rem from https://stackoverflow.com/questions/7985755/how-to-detect-if-cmd-is-running-as-administrator-has-elevated-privileges net session >nul 2>&1 if %errorlevel% equ 0 ( echo Administrative rights check OK ) else ( echo You are NOT Administrator. Start the script from an administrative cmd.exe shell... goto end ) echo Stopping Beszel agent service %NSSMEXE% stop %SERVICENAME% >nul 2>&1 echo Removing Beszel agent service %NSSMEXE% remove %SERVICENAME% >nul 2>&1 echo Deleting installation directory rd /q/s %DESTINATIONDIR% >nul 2>&1 :end ech Done.