'Using Taskkill to kill service, but it restarts

I have this script

    @echo off

sc stop UmRdpService

sc start TermService | find /i FAILED
if not errorlevel 1 (
   taskkill /F /FI "SERVICES eq TermService"
)

takeown /F C:\Windows\System32
Icacls C:\Windows\System32\termsrv.dll /grant %username%:F
del C:\Windows\System32\termsrv.dll
xcopy C:\Source\termsrv.dll C:\Windows\System32\
sc start UmRdpService
pause

In the case that the service doesn't stop lightly I use taskkill, my issue is that the service immediately restarts, I know that because the PID changes.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source