Make Life EasierMicrosoftPrint ServerPrinters

Print Server | Scheduled Task to Clear Jobs and Services

Well all know printers only exists to cause pain. I manage a single windows server with 167 networked printers. Every so often jobs get stuck and I would have to manually go in, stop the print spooler service, clean out the print jobs folder and restart the service. Simple but just gets annoying after the 500th time. So here is my solution

The Batch File

Create a new file in notepad and save it as clear_print_jobs.bat (or whatever you would like) and paste the following code into it. Personally I like to store my scripts at the root of C:\_scripts on all my servers. It’s consistent and easy to navigate.

@echo off
net stop spooler /yes
ping -n 4 127.0.0.1 > nul
del /Q /F C:\WINDOWS\system32\spool\PRINTERS*.*
ping -n 4 127.0.0.1 > nul
net start spooler
echo

This script does the following: stops spooler service, deletes all job files in C:\WINDOWS\system32\spool\PRINTERS, then starts the spooler service.

Scheduled Task

Open up Task Scheduler. Right click “Task Scheduler Library” and select “Create Basic Task”

Create a new basic task

Name it. I called mine Restart and Clear Print Jobs

For the trigger lets do daily (pick which one works for you)

Scheduled Task Trigger

We want it to recur every 1 day. Select an hour that would be the least inconvenient for your staff.

Daily trigger time

Select “Start a program”

Action

Sset the following

Program/script: cmd

Add arguments (optional): /c start “” “C:_Scripts\clear_print_jobs.bat”

Start a Program

Click done. Now in the list of jobs double click the job we just created. On the General tab we need to adjust the security options.

Change the user to a service account you use the job will run under, click “Run whether user is logged on or not” and check “Run with highest privileges

General Settings / Security Options

That’s it! Enjoy the automation!

Show More

Cory Fiala

Technology and outdoor enthusiast. Currently the sole systems administrator for a local K-12 school district with 800+ staff and 5,500+ students. I support windows servers (2012R2-2022), Linux systems (FreeBSD and Ubuntu), along with vSphere (4 node cluster). Total is almost 60 virtual machines and 8 physical servers. This doesn't include my personal homelab.

Related Articles

Leave a Reply

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

Back to top button