Clearing a printers internal buffer?

Started by MW4, June 25, 2013, 11:02:27 AM

Previous topic - Next topic

MW4

I have a Panasonic KX-P2023 dot matrix printer that we use for forms.

When we have a job that gets misaligned during a print that we have to stop mid-stream, we turn off the printer, then go into printers and kill the job (XP.)

When we power the printer back up it keeps printing! It must have an internal buffer that needs to be cleared. Is there anything that I could program that would kill it without powering the printer down and having to kill the job manually?

I figured that maybe someone here would have come across this before.

Thanks, Mike

Deana

You mentioned Windows XP. Maybe give this code a try:
Code (winbatch) Select

; Delete Print Jobs

; Stop the Spooler Service
AddExtender("wwwnt34i.dll")
aService = "Spooler"
state = wntSvcStatus("", aService, 0, 2) ; Get the current state of the service
If state==4 ; Service is running
   wntSvcControl("", aService, 0, 1) ; Stop the Service
   ; Wait for service to stop
   While state != 1
      TimeDelay(1)
    state = wntSvcStatus("", aService, 0, 2) ; get the current state of the service
   Endif
Endif

; Delete files in Spool
FileDelete( DirWindows(0):'\system32\spool\printers\*.shd' )
FileDelete( DirWindows(0):'\system32\spool\printers\*.spl' )

; Restart the Spooler Service
wntSvcStart("", aService, 0, "", "") ; start the Spooler service
Exit
Deana F.
Technical Support
Wilson WindowWare Inc.

rw_baker

Deana,

I tried your code on Windows 7 and it doesn't work...you did specify it was for XP.  Could you alter the code for "7"?

I would like to use it, if possible.

RW Baker

Deana

Quote from: rw_baker on June 26, 2013, 06:40:34 AM
Deana,

I tried your code on Windows 7 and it doesn't work...you did specify it was for XP.  Could you alter the code for "7"?

I would like to use it, if possible.

RW Baker

You mentioned in your original message you were working with Windows XP, so I did some research and wrote the code for you.

Sorry I don't have a code sample for Windows 7.  I recommend doing some research using WMI to delete the file in the printer spool.

Here are some tech articles that should help get you started:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+Tutorials+Printing.txt
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/Printing~Information+Pause~Printer~Queue.txt
Deana F.
Technical Support
Wilson WindowWare Inc.

Deana

Ok here is an undebugged code sample I came up with for Windows 7:

Code (winbatch) Select
; Delete Print Jobs

; Stop the Spooler Service
AddExtender("wwwnt34i.dll")
aService = "Print Spooler" ;Win 7
state = wntSvcStatus("", aService, 0, 2) ; Get the current state of the service
If state==4 ; Service is running
   wntSvcControl("", aService, 0, 1) ; Stop the Service
   ; Wait for service to stop
   While state != 1
      TimeDelay(1)
        state = wntSvcStatus("", aService, 0, 2) ; get the current state of the service
   Endwhile
Endif

; Delete files in Spool
oldvalue = IntControl( 92, "disable", 0, 0, 0 )
FileDelete( DirWindows(0):'\system32\spool\printers\*.shd' )
FileDelete( DirWindows(0):'\system32\spool\printers\*.spl' )
IntControl( 92, "revert", oldvalue, 0, 0 )

; Restart the Spooler Service
wntSvcStart("", aService, 0, "", "") ; start the Spooler service
Exit
Deana F.
Technical Support
Wilson WindowWare Inc.

rw_baker

Deana,

Your code does the job!  Thanks a lot...

RW Baker

Deana

Deana F.
Technical Support
Wilson WindowWare Inc.