script to restart print spooler service

The below VB script can be used to restart print spooler service at regular intervals with Windows task scheduler.

'======================================
'This script serves as a workaround to poorly written printer drivers
'                   
'It checks the spooler folder to see if there are any active jobs.
'If it is empty it will restart the spooler service.
'It works best as a regularly scheduled task.                   
'======================================  

Dim objFSO, objFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")

If objFSO.FolderExists("C:\Windows\system32\spool\PRINTERS") Then
  Set objFolder = objFSO.GetFolder("C:\Windows\system32\spool\PRINTERS")

  If objFolder.Files.Count = 0 And objFolder.SubFolders.Count = 0 Then
objShell.Run "Net Stop Spooler", 0, True
objShell.Run "Net Start Spooler", 0, True
  Else
  End If
End If

7 responses to “script to restart print spooler service”

  1. I enjoyed readiing your post

  2. Excellent article! We will be linking to this great post on our site.
    Keep up the great writing.

  3. […] script to restart print spooler service | Citrixology – The below VB script can be used to restart print spooler service at regular intervals with Windows task scheduler. … How to (correctly) check file versions with PowerShell; PSA: Incorrect MTU size causes connectivity issues with Windows Server 2012 and Windows Server 2012 R2; Mailbag: … […]

  4. […] script to restart print spooler service | Citrixology – The below VB script can be used to restart print spooler service at regular intervals with Windows task scheduler. ‘===== ‘This script serves as a workaround to poorly written printer drivers ‘ ‘It checks the spooler folder to see … ‘If it is empty it will restart the spooler service. … […]

  5. Thanks for this outstanding information.

  6. Hi Pierre,

    Yes it does work on Windows 2003. CPSVC is dependent on the Windows Print spooler so it will restart as well when you restart spooler service. hope it helps

    Lal

  7. Hi there, does it work on win 2k3? and what about citrix printing services? I’m looking to get all the spooler “associated” services like citrix print service to be restarted as well.

    Thanks 🙂

Leave a reply to Lal Mohan Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.