@echo off

net session >nul 2>&1
if '%errorlevel%' NEQ '0' (
    echo Administrator-Rechte sind erforderlich. Fordere Administrator-Rechte an...
    goto UACPrompt
) else (
    goto gotAdmin
)

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
    echo Uninstalling MMI-data4doc-UpdateService
    net session >nul 2>&1
    if %errorLevel% == 0 (
        call "%~dp0StopService.bat"
        sc delete "MMI-data4doc-UpdateService"
    ) else (
        echo Fehler! Es sind Administrator-Rechte erforderlich um den Windows Dienst MMI-data4doc-UpdateService zu entfernen.
    )