WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Printing Information

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Pause Printer Queue


Question:

Is there a way to stop/halt the printer ? I want that the job goes in the queue but then waits until I let it print out...
W2K - SP2
WB2004A 

Answer:

You maybe be able to pause the printere using WMI 'Pause' method in the Win32_PrintJob class.

http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_printjob.asp?frame=true

For help writting the WMI code see the WMI scripter utility:

If licensed with 2004C:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/WMI/WMI_Scripter/2004B~and~Newer+!!~WMI_Scripter~!!.txt

If older version:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/WMI/WMI_Scripter/2004A~and~Older+!!~WMI_Scripter-Older~!!.txt


;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; How to execute the Pause method from the
; Win32_PrintJob class
; 
; The Pause WMI class method suspends a print job. 
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer()
Security = Service.Security_
Security.ImpersonationLevel = 3
Class = "Win32_PrintJob"
Instance = Service.InstancesOf(Class)
hEnum = ObjectCollectionOpen(Instance)
While 1
  Obj = ObjectCollectionNext(hEnum)
  If Obj == 0 Then Break
  ;Execute the Pause() method on object
   Obj.Pause()
EndWhile
ObjectCollectionClose(hEnum)
ObjectClose(Instance)
ObjectClose(Security)
ObjectClose(Service)
ObjectClose(Locator)

Exit

User Reply:

That doesn't seem to be really easy... And it seems to need a job which already is in the queue.

Is there no (more easy) way to halt the printer before the job comes in ?

Answer:

Try this:
printer = "\\VS-HV111\D-HV025"

;pause printer
RunShell("rundll32","printui.dll,PrintUIEntry /Xs /n %printer% status pause","",@HIDDEN,@NOWAIT)

;delete all printjobs
RunShell("rundll32","printui.dll,PrintUIEntry /Xs /n %printer% status purge","",@HIDDEN,@NOWAIT)

;release printer
RunShell("rundll32","printui.dll,PrintUIEntry /Xs /n %printer% status resume","",@HIDDEN,@NOWAIT)
Exit

Article ID:   W16663
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38