Home All Groups Group Topic Archive Search About

Script to restart service

Author
4 Apr 2005 1:04 PM
Marco
One of our services seems to be freezing almost daily.  We will be upgrading
the server in a few weeks which should take care of the problem but until
then I was wondering if there is a way to setup a script that would
automatically restart the service whenever it stops.  Were using NT4.
Thanks.

Author
4 Apr 2005 1:21 PM
Allen Firouz
Marco:

Here is a sample.  Modify as needed: 
http://cwashington.netreach.net/depo/view.asp?Index=539&ScriptType=command

-Allen Firouz

Show quoteHide quote
"Marco" wrote:

> One of our services seems to be freezing almost daily.  We will be upgrading
> the server in a few weeks which should take care of the problem but until
> then I was wondering if there is a way to setup a script that would
> automatically restart the service whenever it stops.  Were using NT4.
> Thanks.
>
>
>
Are all your drivers up to date? click for free checkup

Author
4 Apr 2005 1:24 PM
Marco
Thanks

Show quoteHide quote
"Allen Firouz" <AllenFir***@discussions.microsoft.com> wrote in message
news:41B52F39-96BC-46B7-9E92-739B6A3C1201@microsoft.com...
> Marco:
>
> Here is a sample.  Modify as needed:
> http://cwashington.netreach.net/depo/view.asp?Index=539&ScriptType=command
>
> -Allen Firouz
>
> "Marco" wrote:
>
>> One of our services seems to be freezing almost daily.  We will be
>> upgrading
>> the server in a few weeks which should take care of the problem but until
>> then I was wondering if there is a way to setup a script that would
>> automatically restart the service whenever it stops.  Were using NT4.
>> Thanks.
>>
>>
>>
Author
4 Apr 2005 1:23 PM
Jerold Schulman
On Mon, 4 Apr 2005 09:04:51 -0400, "Marco" <nospampleasesyxxpk@hotmail.com> wrote:

>One of our services seems to be freezing almost daily.  We will be upgrading
>the server in a few weeks which should take care of the problem but until
>then I was wondering if there is a way to setup a script that would
>automatically restart the service whenever it stops.  Were using NT4.
>Thanks.
>


You can start a batch from the AT service:

at HH:MM "C:\Folder\batch.bat"
where HH:MM is 2 minutes in the future.

Assuming the service display name is "my service", batch.bat could contain:

@echo off
setlocal
:loop
@ping -n 61 127.0.0.1>nul
set OK=N
for /f "Tokens=*" %%a in ('net start^|FIND /I "my service"') do (
set OK=Y
)
if "%OK%" EQU "Y" goto loop
net start "my service"
goto loop

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com

Bookmark and Share