Restarting services

Here’s a quick tip on how to restart a service when a specific event is logged in the event logs. Let’s say for example that you want to restart a service such as the SQL Server service when an event with a specific event ID is logged in the Windows event logs. You can do this as follows:

  1. Open Event Viewer and navigate to the log that contains the event you want to associate with a task.
  2. Right-click the event and select Attach Task To This Event.
  3. Walk through the Create Basic Task Wizard to create the new task.
  4. Create a simple batch file with sc stop service_name and sc start service_name.
  5. Open the task you just created and edit it to make the action performed by the task to be running the batch file.
  6. Edit the task to specify the event ID needed to trigger the task.
  7. Save the changes to the task.

The above tip was previously published in an issue of WServerNews, a weekly newsletter from TechGenix that focuses on the administration, management and security of the Windows Server platform in particular and cloud solutions in general. Subscribe to WServerNews today by going to http://www.wservernews.com/subscribe.htm and join almost 100,000 other IT professionals around the world who read our newsletter!

Mitch Tulloch is an eleven-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows Server and cloud computing technologies.  Mitch is also Senior Editor of WServerNews. For more information about him see http://www.mtit.com.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top