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:
- Open Event Viewer and navigate to the log that contains the event you want to associate with a task.
- Right-click the event and select Attach Task To This Event.
- Walk through the Create Basic Task Wizard to create the new task.
- Create a simple batch file with sc stop service_name and sc start service_name.
- Open the task you just created and edit it to make the action performed by the task to be running the batch file.
- Edit the task to specify the event ID needed to trigger the task.
- 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.