setting a default printer

Started by MW4, October 18, 2022, 06:26:17 PM

Previous topic - Next topic

MW4

Our process server has several printers installed and I have a need to print to a specific one.

What I'm trying to set up is a folder, where PDF's get deposited, and then depending on the folder prints to that specific printer.

FolderPrinter1 prints to Printer1 then moved the file to an archive folder Printer1Archive (one sided)
FolderPrinter2 prints to Printer2 then moved the file to an archive folder Printer2Archive (two-sided)
FolderPrinter3 prints to Printer3 then moved the file to an archive folder Printer3Archive (special paper)

I have the mechanism to do something when a file hits, it's just the printing which is the issue.
It seems like I would just set the needed printer to be the default printer, and then after re-set it to the real default printer after it is printed and then archived.

I can't seem to find examples of setting the default printer. Can someone point me in the right direction?

JTaylor


MW4

That led me to the tech database where I found this and it works for what I need to change the printer and print:

But how do I kill the acrobat session via code that is created??


Run('rundll32.exe', 'printui.dll,PrintUIEntry /y /n "1 Side printer"')

Code (winbatch) Select
;set working directory
pdfdir="c:\incoming\1 work\" ;needs trailing \
DirChange(pdfdir)

BoxOpen("PDF Print","")

;get list and count of pdf files.
pdflist=FileItemize("*.pdf")
pdfcount=ItemCount(pdflist,@tab)

;Get PDF printing command line
pcommand=RegQueryValue(@REGCLASSES,"AcroExch.Document\shell\print\command")
;set lower case for easier parsing
pcommand=strlower(pcommand)
;break it into exe and param section.
;find the /p
ptr=StrIndex(pcommand,"/p",0,@fwdscan)
;grab previous stuff
exepart=strsub(pcommand,1,ptr-1)
parampart=strsub(pcommand,ptr,-1)
;clean up exe part
exepart=strtrim(strreplace(exepart,'"',''))


for xx=1 to pdfcount
   thispdf=ItemExtract(xx,pdflist,@tab)
   BoxText(thispdf)
   thisfullpdf=strcat(pdfdir,thispdf)
   thisparams=StrReplace(parampart,"%%1",thisfullpdf)
   Run(exepart,thisparams)
   WinWaitExist("Print",30)
   SendKey("~")
   ;Message(exepart,thisparams)
next

Message("All","Done")



JTaylor

Does the WinBatch Print command cause the same problem?

Jim

JTaylor

You might find that using something like Sumatra PDF is a good way to go.   You can just print to whatever printer you want without changing anything.    Look at the print-to option under the command-line options in the Manual.


Jim