Batch programming, stopping and starting services

Save to terminate service with taskkill when trying to stop using NET STOP failed? And if I end it with taskkill, will the NET START command have an effect or will I need to use the START command ?

consider this code as an example:


@ECHO OFF
:STOP
NET STOP someservices
IF ERRORLEVEL == 0 GOTO :START
GOTO :KILL

:START
NET START someservices

:KILL
TASKKILL /F /IM someservices.exe
SLEEP 10
START someservices.exe 

      

+1


a source to share


1 answer


Use SC instead of NET - it won't work.

Billy3



EDIT: And it will be difficult for you to kill many services that may be using the same process. EDIT2: see this for more details -> http://support.microsoft.com/kb/314056

+1


a source







All Articles