Link to home
Start Free TrialLog in
Avatar of Brent
BrentFlag for United States of America

asked on

Script to enable auto recovery?

We have a few printers that are causing the print spooler service on computers around the company to stop.

Is there a way to script a logon file that can set the recovery options under the print spooler service to automatically restart if failed and set the option for delay to 3 minutes?

Avatar of avatar-e
avatar-e
Flag of Chile image

This script keeps prints spooler alive, checking every 3 minutes
' ReStartService.vbs
' Sample script to Stop or Start a Service
' www.computerperformance.co.uk/
' Created by Guy Thomas December 2005 Version 2.4
' -------------------------------------------------------' 
Option Explicit
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService, intSleep 
strComputer = "."
intSleep = 180000
'WScript.Echo " Click OK, then wait " & intSleep & " milliseconds" 
 
'On Error Resume Next
' NB strService is case sensitive.
strService = " 'Spooler' "
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService & " ")
 
While true
For Each objService in colListOfServices
objService.StartService()
WSCript.Sleep intSleep
Next 
wend
WScript.Echo "Your "& strService & " service has Started" 
WScript.Quit
' End of Example WMI script to Start / Stop services

Open in new window

Save to a VBS file and double click it (or put in the startup folder in the faulty print server)
Avatar of Brent

ASKER

Thats a nifty script... question though.

I would be using this for computers in which users login.   If its apart of the login script, wouldnt it cause mutliple instances of this script to run?
You can put the script just in the admin account to start it once, on the startup folder in start menu / programs. (If you start as admin first).

ASKER CERTIFIED SOLUTION
Avatar of avatar-e
avatar-e
Flag of Chile 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
Avatar of Brent

ASKER

Thanks.. not exactly what i wanted, but its actually a better solution :)