All Collections
Troubleshooting
How to restart a service using Task Scheduler
How to restart a service using Task Scheduler

Restart service using Task Scheduler

Paul Csiki avatar
Written by Paul Csiki
Updated over a week ago

Some of you may have noticed that with the introduction of Pulseway 6.0 Actions became no longer supported from the Rules module. Currently we are working on a new feature that will allow script execution based on a notification status, however, that's still on a drawing board.
As a temporary workaround we would suggest to create a new entry in the Task Scheduler and pair it up with the below script that will allow you to monitor and start/stop a service in case of any problems.

To start navigate to Control Panel -> Administrative Tools and select the Task Scheduler icon (or simply start it from command prompt with taskschd.msc)
Once done create a new task by right click on the Task Scheduler Library.

Configure the General, Triggers and Actions tabs as per the below.
Conditions and Settings tabs can be left as default.

the 'Repeat task every' drop down menu allows you only to select 5 minutes as the shortest time interval, please overwrite manually to 1 minute

Create the watchservice.bat file as per the below instructions and save it into a convenient location. Once done, add the file location in the Actions tab

Script:

To create the watchservice.bat file copy the below script, amend the service name, paste it into a Notepad document and save as a batch file.

@ECHO OFF

SC QUERYEX "Spooler" | FIND "STATE" | FIND /v "RUNNING" > NUL && (
NET START "Spooler" > NUL || (
        EXIT /B 1
    )
    EXIT /B 0
) || (
    EXIT /B 0
)



Did this answer your question?