Код:
@echo off
set "service=имя службы"
for /f "delims=" %%i in ('
"wmic SERVICE where Name="%service%" get PathName| findstr \\"
') do (
set x=%%i
call set "y=%%x:*.exe=%%"
for /f "delims=" %%j in ('cmd /v:on /c call echo "!x:%%y%%=!"') do (
taskkill /f /im "%%~nxj"
del /a/f %%j
sc delete "%service%"
)
)
exit /b