Dels
Dels

Reputation: 2425

Batch programming, stop and start services

It is save to terminate the services using taskkill when the attempt to stop using NET STOP was failed? And if i terminate it using taskkill, do NET START command will affect or do i need to use START command?

consider this code as 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 

Upvotes: 1

Views: 1520

Answers (1)

Billy ONeal
Billy ONeal

Reputation: 106549

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

Billy3

EDIT: And you will have difficulty killing a fair number of services which can share the same process. EDIT2: See this for more details -> http://support.microsoft.com/kb/314056

Upvotes: 1

Related Questions