Link to home
Start Free TrialLog in
Avatar of jack niekerk
jack niekerkFlag for Netherlands

asked on

IN VB6 OR COMMANDLINE SETTING PRINTER OFFLINE AND ONLINE

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
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

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
Avatar of jack niekerk

ASKER

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?
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
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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