# Jesus 'n Jim

A mainly PC (some Mac) site w/Software, Computer Repair Info, How-To's on Using Computers
Technical Support 1-360-521-2060 (my business line cell)

# stuck print jobs

## Overview

The 2000/xp/vista family of operating systems is the worst when it comes to print jobs getting stuck in windows' print spooler when there's an error from the printer. This is from close observation of and experience with the 3 error state machines involved with a Centronics parallel printer, the usb-to-IEEE-1284 cable, and the computer's print spooler service on XP. You can probably apply the same logic you find here to windows 9x/ME and NT if I remember right (little fuzzy now).

If your print job gets stuck in the printer spooler, don't repeat it on a different computer/printer (if it jammed one printer/computer it could easily jam another). delete the print job and get your IT(Information Technology/Computer) Guy help to fix the printer. Thank you.

## Causes

• jobs are too big for printer's or spooler's memory. If you have a really big print job, you may want to go to a mac (which is UNIX based), or go to a UNIX/Linux machine. I have seen this on large color copier/printers.
• special USB-to-IEEE1284(Parallel/Centronics) printer adapter cable error.
• It's a Lexmark. it just happens. they do strange things to the OS configuration to make the drivers work. Specifically, they do something wrong with RPCSS. Brad Kovach wrote a print flush utility which fixes this problem (it also purges the entire spooler of jobs, you can customize it if you are a sysadmin)

check out my blog for printflush

## Solution 0: The easiest way to fix the print queue

1. Run Brad Kovach's batch file (see blog) or my improved batch file (v1.3.1), (works with windows versions 9x-7) that zaps the print jobs in the print queue and stops and restarts the `Print Spooler` service, or my C program printflush which has an installer that simply zaps the jobs and is also compatible with windows 9x-7. You may still need to disconnect your device from your computer and try this again, but try this first and see if it works. You will lose your print jobs.
2. If this does not immediately allow you to print new jobs, do the following steps (you want to clear the printer errors while the printer is disconnected:
3. disconnect your printer cable from the computer. [you don't want the computer stuffing jobs into the printer while there's an error. only makes things worse.]
4. turn off any printer-related peripherals, such as print servers. [you don't want those trying the stuff the printer with jobs while there's an error, just makes things worse.]
5. fix any printer errors such as out-of-ink, out-of-paper, etc, paper jams.
6. turn off the printer.
7. run the batch file again. The queue should be clear now.
8. If it is, then turn your printer back on.
9. turn on your computer-related peripherals last.

## How to delete print jobs

The printer connectoids are in Start|Printers or Start|Settings|Control Panel|Printers (or Start|Printers and Faxes if you are on 2000/XP/Vista). One of these should work fine. Just look for Printers.
Double-click on the printer connectoid to get at its computer print jobs. From these you can left-click on the top job, hold down the shift key on the keyboard and left-click on the bottom job to select them all (you can use this trick with nearly any windows application to select a set of items), and hit the Delete key on the keyboard to delete those jobs. If you have only 1 job just click on it and hit the delete key. You may have to wait a long time for the print job to clear depending on whether the printer needs to be fixed or not.

If you want to see what jobs are in the queue, do from a cmd shell: `dir "%windir%\system32\spool\printers\"` if you are on an NT-family system and `dir "%windir%\spool\printers\"` if you are on a windows 9x/me system. it's best if you put that in a batch file with a .bat or .cmd extension. to list the files on a windows server print spooler, do `dir "\\computername\C\$\windows\system32\spool\printers\"` I use double quotes in case the path has spaces in it.

to delete a job on windows nt family systems, from the cmd shell type `net print` to get the command syntax for the net print command. to delete a job from a specific computer, `net print \\computername\sharename job# /delete`

you can also start the spooler with `net start spooler` and stop the spooler with `net stop spooler`.

## How things work

• The Windows Print Spooler is like a triggered latch: it is triggered into the error state by a printer error and will stay in the error state as long as the printer is in the error state *and* there are jobs in the print spooler *and* the printer has not been disconnected for a while. I have determined this to be a bug Microsoft didn't catch.
• The Windows Print Spooler will stay in the error state as long as there is a printer error.
• The Windows Print Spooler will stay in the error state as long as there are print jobs in the computer's print spooler.
• The Windows Print Spooler's error state is sticky. Once it is in the error state, it stays there until all 3 conditions clear it out for a at least 15 minutes.
• The computer must be on in order for Windows Print Spooler to clear.
• If it is an old printer that doesn't turn on when the job comes into the Windows Print Spooler, printing while the printer is offline or off will cause a Windows Print Spooler error once the printer is turned on (your mileage may vary with printer model).
• Stopping and starting (bouncing) the Windows Print Spooler service on the computer will only cause the need for a reboot (printer drivers & software need to be restarted!).
• Shutting down/restarting the computer will only keep the print jobs in the Windows Print Spooler and restart the jobs on startup, if that is what you want (probably not in this case!).
• The Windows Print Spooler will continue trying to push the [bad] print jobs even during the error state, waiting/trying to finish its jobs (but since the Windows Print Spooler is error-latched, from what I have seen, it never succeeds. (let me know if this is not the case)
• You can try to delete Windows Print Spooler jobs as long as you are in the error state, but the Windows Print Spooler won't let go of them until you disconnect the printer or the computer from the network if it is a network printer. It may also be possible to remove the printer connectoid (have not tried that recently) to resolve the problem.
• If you have a bad print job on one of the computers that can jam a printer and you have gotten your printer all fixed up and the print job is still in the queue, you're back at the beginning of the error loop.
• The only thing that seems to clear the Windows Print Spooler from its error condition latch is A: having all its print jobs gone AND B: the printer out of its error state.
• if the computer is disconnected from the printer and a job/the jobs is deleted, it will disappear from the queue eventually. It takes a while though.
• The printer must be online before you start printing [on some older printers only?] or the printer may cause an error state. I don't think this applies to network printers which have an internal smart job queue/spooler and the offline status of the printer doesn't affect the queue/spooler. Watch to see how your printer acts, or if you can spare some of your own personal bandwidth to test things. Newer inkjet printers wake up when they are off if you print to them, and there is no offline button. I think there is an offline button/mode on networked printers, but I haven't seen the newer ones yet.
Think: to do this, you must clear ALL the print jobs from the windows' print spooler on the computer that is in the error state. this is a requirement to get it out of the error state. [you need to do this to all errored computers - this means all computers connected to the printer that have jobs]. you must also disconnect the printer(USB/network/wireless) and powerdown / reset it and clear its queue somehow, especially if the printer is networked. This is the only way to get you to the place where you can get out of the windows print queue error state (per computer).Once the printer is disconnected, you must wait while the computers are on for their respective print queues to clear out. This will take a few minutes. Make sure you fix the printer's error condition too while things are disconnected.

## SOLUTION 1:

1. delete *ALL* the print jobs on every computer that feeds the printer (they will stay stuck until the printer is out of the error state), and keep people off of the printer until you have time to fix it. Leave the computers on so they can clear their print queues.
2. disconnect the printer from the computer (if that means disconnecting the computer from the network - you don't have to remove the printer connectoid - that means reinstalling software & drivers!) OR disconnect the errored computers from the network.
3. disconnect the print servers or related print peripherals. This step may not be necessary. You may not want the print server stuffing jobs into the printer while the printer is in the error state, it may keep the printer in the error state.
4. and wait until *ALL* the jobs clears the print spooler on ALL the errored computers. [I am not a network admin, so I have no exp. in this area, but I basically can avoid this at home because I am using a single computer as the spooler. You may need to do this if it is a network printer, but my guess is they are made well enough that you won't need to very often except to hit the reset button.]
5. clear the print queue on the printer and reset the printer or cycle the power, clear print jams, fix the out-of-paper problems - do whatever you have to do to the printer to get it out of that error state and the print jobs cleared.
6. turn on the printer and make sure it is online.
7. turn on the printer peripherals.
8. the error state will not clear if the printer is offline and a job comes in and you have a usb-to-IEEE cable. You should not have this problem with a newer printer since USB came out, but try to follow this anyway - saves headaches.

## SOLUTION 2: (if you loathe to disconnect cables)

I have not tried this solution but it should work, if windows will allow you to delete a printer connectoid that has print jobs. If you are using a central computer as a print spooler, you can install the drivers on it, and the drivers for Windows will be copied down the network to your remote PC's, saving you from sneaker-net.
1. delete all print jobs from every computer feeding the printer (they will stay stuck until the printer is out of the error state). leave the computers on so they can clear their print queues.
2. delete the printer connectoids from AT LEAST the offending computers, perhaps *ALL* computers connected to that printer, and keep people off of the printer until you have time to fix it.
3. clear the print queue on the printer and reset the printer or cycle the power - do whatever you have to do to the printer to get it out of that error state and the print jobs cleared.
4. reinstall the software and drivers for the printer on the computers that you removed the connectoids from. you will probably have to, because once the connectoid is removed, the drivers disappear too and your software gets disconnected.
5. make sure the printer is online before printing jobs. the error state will not clear if the printer is offline and a job comes in and you have a usb-to-IEEE cable. You should not have this problem with a newer printer since USB came out, but try to follow this anyway - saves headaches.

## USB-to-IEEE-1284 cables

These things have integrated electronics and have their own aggrivating smarts when handling error conditions. They get stuck in an error condition, just like windows (and certain printers sometimes). The only thing that removes the error condition of the cable is disconnecting the cable from all power sources (and having the printer cleared of an error condition). This usually means turning off the power to the printer AND disconnecting the USB plug (USB end). The printer supplies +5V power to the printer cable. so does the USB cable. Both are power sources. We want them both off.

we have this problem all the time on our own old USB-to-IEEE-1284(Centronics Parallel) home laser printer and it does this a lot (whenever the printer is offline the print spooler gets jammed). This is not the only printer/computer this happens to. the problem is the windows print spooler was not designed correctly and also has not been fixed by microsoft (somebody please complain to microsoft for me).

I have tried many solutions:
• deleting the print job from the computer
• deleting the print job from the computer and stopping the spooler service.
• deleting the print job, stopping the spooler service, and rebooting the computer.
• deleting the print job from the computer and disconnecting the printer interface
• etc.
The only thing that has worked for our small home printer that resets the printer's and the usb-to-IEEE1284 cable's and the spooler's error state (there are 3 separate error states to deal with! the printer and the embedded cable electronics...) is:
1. turning off the printer
2. disconnecting the USB cable (USB end)
3. deleting ALL the print jobs
4. waiting for the jobs to clear the print spooler/queue
5. connecting everything up and turning the printer on
6. WAITING FOR THE PRINTER TO GO ONLINE BEFORE PRINTING JOBS.

Many times what causes our printer/spooler to get into the error state is having jobs in the spooler when the printer is off, or printing while the printer is offline. Disconnecting the USB cable causes some extra wear on the USB port, but nothing else works - USB is powered by the computer so the usb cable's error state (fed by the printer) gets latched and stuck. as long as the USB cable gets power, you have an error state in the USB-to-IEEE cable.
I don't think you will have this problem with newer printers that have the USB interface built-in unless the printer gets jammed. They do not have an online/offline button, and the printers are turned on automatically when a print job goes into the spooler (it's a function of the fancy printer [driver] software).

## Network Printers

Network printers's print spoolers don't get stuck in an error state that I have ever seen. They are designed not to cause network downtime! HOWEVER - the printer itself could possibly be fed a job that jams it.
Uses too much memory for example. Fed it a weird command sequence that it doesn't parse right. Buffer overflow is quite possible. The printer was written with software and software can have bugs/design flaws because it was written by flawed human beings who can't think of and handle every situation that could possibly come up. But they get most of the situations pretty well. Paper jams can do it too, but that's not a software problem. Possibly the same solutions as outlines above (1 and 2).

Network printers are mostly trouble-free from what I have seen (but then again, I have not been the network or IT admin - somebody fill me in!).

## USB Ink-Jet printers like my Dell 922

...sometimes have the need to be powered down too. It has gotten jammed a few times and the print queue gotten stuck with some kind of an error condition (once in a long while with a call to Dell tech support to shake the printer a certain way a few times to fix it - specific to this model), and I have had then to
1. disconnect the power cable to the printer, which disconnects the USB device (printer) from the computer and also resets the printer.
2. double-click the printer connectoid to see the print jobs.
3. delete ALL the print jobs in the print queue/spooler on the computer.
4. wait for the print jobs to clear.
5. plug the power cable back into the printer.

## [Printer] error State Machines

As for my situation, The 3 state machines involving

1. the smart USB-to-IEEE1284 cable,
2. the printer (An Okidata OL-810e mono laser printer), and
3. the XP computer's print spooler,

can be observed by watching how deleted jobs react under different combinations of the following:

1. the printer is off or on.
2. the cable is connected or disconnected. (USB end)
3. there are print jobs in the queue or not.
4. the printer has had an error.
5. the printer is online/offline.

Since there are 5 sets of binary conditions, there are a total of ${2}^{5}=32$ different combinations to test.
There are only ${2}^{4}=16$ if you don't have a USB-to-IEEE-1284 cable and you instead have a direct network connection or a direct USB cable or wireless.
You can eliminate 1/2 of a condition (making 3 states instead of 4 for the cable and eliminating 1/2 of the number of tests) by the fact that the printer supplies power through the centronics/IEEE1284 interface and the USB interface supplies power. If either end of the cable is powered, the cable is live and holds its error state - to be off (and reset), both ends must be either off or unplugged.
To be honest, I don't think I tested them all (paper & toner being precious), but I did learn a lot from the many error conditions I regularly have to clear.

FYI: Finite State Machines have specific defined states that they can be in (not like Wyoming, but a state of being: like hot or cold, or for an elevator, floor numbers or "motor moving" or "jammed" or "door closed" or "door open"). Conditions cause the state machine to transition from one state to another, or even to loop back to the same state. The link points to a wikipedia article with diagrams on the subject. Diagram: the circles are states, and the arrows from circle to circle take you from state to state (the transitions), and the writing on the arrows are the conditions. (this diagram was made using the free ArgoUML). This is a simplified diagram for helping you understand how to fix things. (I have not as yet figured out how to make statecharts with complicated conditions)

Actually, if you are into electronics, the "error latch" I am talking about acts most like an SR Latch with a 2 or 3-input or gate on S (Set) and a 2-input AND gate on R (Reset). it is also known as a flip-flop these days for some reason. here is a an equivelant electronics schematic of how the logic behind everything really works: (this schematic was made using the free Dia)

The boolean logic to set a spooler error based on this schematic is (printer_error OR ((spooler_error OR printer_error) AND jobs_in_spooler)).
The reset logic is ((no_jobs_in_spooler AND printer_disconnected AND no_printer_error)[delayed] OR (no_jobs_in_spooler AND no_printer_error AND no_spooler_error)).

Note: If you made a network printer connectoid that is based on an IP address that changed, it is possible the only way you can delete that connectoid is via the registry (XP) in
`HKCU\Printers\Connections`
`HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices`
`HKCU\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts`
`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\LanMan Print Services\Servers`
`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WinSS\{B212D2AC-A5AD-4255-913C-EF49A3B75F7C}` (be careful with this one, requires text editing that can be a headache, and I don't recommend it!).
WARNING: editing the registry is dangerous to your computer and can cause it not to work right - if you do it, it is at your own risk - you were warned!

I hope my research saves you some headache.