We help IT Professionals succeed at work.

IN VB6 OR COMMANDLINE SETTING PRINTER OFFLINE AND ONLINE

jack niekerk
jack niekerk used Ask the Experts™
on
Having these  lasers with 5 papertrays  for input
only 1 output bin

I print mutiple  sets of documents per document  setting a papertray  due to different color in paper
then the colors must stay together in output bin
if I start printing right away they are unsorted by color in output bin

I  print  some  50 documents to  printers called BLEU, WHITE , GREEN ,YELLOW,PINK wich are installed copies of same printer
with each having their preferred  tray

Thus printing to each printer based on tray

Now by hand BEFORE starting print job I set  all printers to offline
then start printing
all output will be in  each printer buffer on hold

Then by hand turn one by one the printer online again after a set in each named printer is empty
this way all colors are on output bin  together

so to make it automatic i need a  programmable  way ,   to turn printers on and off line
printer is a  Kyocera ECOSYS P3260dn KX
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You may use Win32 API functions for Print Spooler: https://docs.microsoft.com/en-us/windows/win32/printdocs/printing-and-print-spooler-functions
SetPrinter is your friend: https://docs.microsoft.com/en-us/windows/win32/printdocs/setprinter

This all is rather complex… The Printer status appears in several PRINTER_INFO structures and I would recommend to start with reading printer settings by GetPrinter: https://docs.microsoft.com/en-us/windows/win32/printdocs/getprinter

Code sample is e.g. here: http://www.vbforums.com/showthread.php?729313-2010-How-to-get-printer-status

Author

Commented:
would be nice if samples in Win32 API functions for Print Spooler where for vb6  C++ is not a option for me  
he code sampels in vb formums gives as far i see only status of printer not setting a printer to some status like offline
but thanks anyway for your time
Yes, I wrote it is rather complex... OTOH, to convert C++ code calling Win32 API into VB6 or VB.NET should be relatively easy. But you have to be ready for all the traps the Print spooler manipulation brings. This will surely mean hours of testing.

Wouldn't it be easier to have one printer and control what tray is used for the current printout?

Commented:
Not on my pc at moment to check but you can call the built in vbscript management tool or wow your own Vbs code which you could easily run from commandine / batch.

I'll check whether it does show offline/online as suggested when on pc later.

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc725833(v%3Dws.11)

Steve
Commented:
I tried this as I suggested above and it works fine for me:

Offline
cscript "C:\Windows\System32\Printing_Admin_Scripts\en-us\prncnfg.vbs" -t  -p "Brother DCP-L8400CDN Printer" -workoffline

Open in new window

Online
cscript "C:\Windows\System32\Printing_Admin_Scripts\en-us\prncnfg.vbs" -t  -p "Brother DCP-L8400CDN Printer" +workoffline

Open in new window


So you could lop through and mark them all as offline /online as needed with that -- you can call cscript from your VB6 program with Shell for simplicity or you could pick apart the built in scripts.

Steve

Author

Commented:
why are things sometimes so simple...  and why even me as a old (started 1980) programmer do we not allways know
these  things!
even works if printer is not default printer
But it works !!!
 thanks a lot for helping Steve and have a nice Christmass

Author

Commented:
hello Steve using this i  add one more question on the forum please take a look at it
Tiltle:    Finding out status of printspooler empty or not
regards Jack