Print Queue Kerfuffle

12/5/2022

By: Zachary Hite

So I had something happen at work last week that I figured I would make a quick post about.

We have a label printer (brand which shall remain nameless but might have something to do with a striped horse). This printer will randomly error out a job sent to it and prevent anything further from printing as it is stuck in the Print Queue. The printer is USB attached and not networked at all. I tried a variety of driver versions on it ranging from old to current and it continued to do this error.

Seeing as it was Friday night and I needed to be home urgently for a family function I couldn’t spend much more time on this particular problem. The only way that you could clear the queue was to shut down the print spooler service, then clear the queue and then restart the print spooler service.

Not something I really wanted to teach the end user on a Friday night and then have go awry over the weekend shifts, as each shift would have to teach the next one how to do it. I really wasn’t looking forward to that weekend call. (Plus I am not paid for on-call).

So instead I did the following.

Making a new .txt file I wrote this script…

echo Please wait while the Print Queue is forced clear….
@echo off
net stop spooler
del /a /f /q “C:\Windows\System32\spool\PRINTERS*”
FOR /D %%p IN (“C:\Windows\System32\spool\PRINTERS*.*”) DO rmdir “%%p” /s /q
net start spooler
@echo off
echo ….
echo Okay! You can close the window and try printing again!
echo Please let the IT Dept know that you had to use this file!
timeout /t 20

Okay so lets ignore the “echo” command sections and focus on what is being executed. Then after that explanation I will explain how I set this up for the user to execute as that is important as well.

First I use the net stop spooler command to well stop the spooler (probably didn’t need to explain that one… oh well)

Then next I preformed a delete command…

del /q “C:\Windows\System32\spool\PRINTERS*”
FOR /D %%p IN (“C:\Windows\System32\spool\PRINTERS*.*”) DO rmdir “%%p” /s /q

This looks into the directory where the print queue jobs are stored and removes the folders and files.

Then lastly I restart the spooler. The rest of that is simply fluff to communicate with the end user.

So then the question is how do you get the user to execute this script? Well for me since I needed the script to run with admin permissions I stored the file on a folder in the C drive and then I created a shortcut to it and set that shortcut to run as admin, as I could not have the bat file itself set to run as admin.

How you set a shortcut to run as admin is by creating the shortcut then going into its properties, selecting “Advanced” and then checking the “Run as Administrator” option.

Hope this helps someone else in the future. Obviously this is not a long term solution but I am working on that and this at least keeps us moving forward.

Leave a Comment

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