Determine Default Printer

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Determine Default Printer

Post by kpassaur » Thu Jun 29, 2006 10:43 am

What I am trying to do is use a command line to print a file, which is no big deal. However, it naturally goes to the default printer. This is where the issuse it. I want to be able to print to a specific printer without user intervention (MS)

My thought was to change the default printer using

RunDll32.exe printui.dll,PrintUIEntry /y /n "[Printer Display Name]"

Then I would print my job and then change the default back.

Which should work. However, after I change the default printer I need to change it back. Since I don't know the name of the default printer before I change it, I am stuck.

Is there any easy way to determine it? I have looked and found complex scripts and some Dlls but nothing seems to work right. I like the one Marcus posted that allows you to change the printer, but it dosn't display what is currently the default.

Also, I have found this webpage that has execellent help for RunDll32.exe if anyone is interested



http://www.dx21.com/SCRIPTING/RUNDLL32/REFGUIDE.ASP?P=A

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jun 29, 2006 11:06 am

How about this:

Code: Select all

RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Windows NT\CurrentVersion\Windows,Device,DefPrinter
Let>DefPrinter={Copy(%DefPrinter%,1,Pos(",",%DefPrinter%)-1)}
MessageModal>DefPrinter
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

How do you know all of this

Post by kpassaur » Thu Jun 29, 2006 11:15 am

I would have never though of doing it that way and it works great. I spent 4-5 hours trying to find a way and from posting on this forum to you responded was only 10 minutes. Your support is great.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts