Link to home
Start Free TrialLog in
Avatar of sunhux
sunhux

asked on

Change a Windows Batch script to non-interactive Windows service that auto-starts if it detects it's down

I have a windows batch script that I would like to run as a Windows Service
(non-interactively ie it's running even before user login to Windows) &
this Service should check if it's down/not running & then auto-start
(auto-start when Windows boots up but also auto-start when the
 service is down/not running).

User must not be able to set this service to shut down or Disabled or
Manual;  only local administrator or domain admin can be allowed to
do this.  I'm running on Win 7 & Win 10.

Appreciate a step by step instruction, thanks.
Avatar of ste5an
ste5an
Flag of Germany image

Run it as scheduled task.

The only question is, why do you need it? Just configure your service accordingly.
ASKER CERTIFIED SOLUTION
Avatar of John
John
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Easy.

@ECHO OFF
:Start

REM Your batch file

REM Sleep for a minute
Timeout 60

REM Run again
Goto Start

Open in new window


Then add it as a service via NSSM
https://nssm.cc/
Thanks and I was happy to help you with this.
The selected answer does not answer your question.

How does
An ordinary Service can be set to Automatic and then in the Recovery tab, restart itself if it does not start the first time. Only Administrators can adjust these services.

answer this?
I have a windows batch script that I would like to run as a Windows Service
(non-interactively ie it's running even before user login to Windows) &
this Service should check if it's down/not running & then auto-start
(auto-start when Windows boots up but also auto-start when the
 service is down/not running).
Reading between the lines, it seems the Recovery option may have fixed the issue without a script ... we'll see!
It cannot because it's not a service to start of with. The question is how to turn it into a service