Using ShellExecute to Print an HTML file to the default printer


I am trying to use ShellExecute to print an HTML file to the default printer without popping the dialog up.  I have read about using the "printto" verb, but can't figure out the exact syntax to get it to work.

I have first been trying to get it to work when I hardcode the name of my default printer.  Then I need to figure out how to obtain the name of the default printer and send it to it.

Here is my current code:

ShellExecute(NULL, "printto", path, "\"Adobe PDF\"", NULL, SW_HIDE);

But it still pops up the dialog.  Anyone been able to get this to work?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

printto actually calls
rundll32.exe %SystemRoot%\system32\mshtml.dll,PrintHTML "%1" "%2" "%3" "%4"

So the question is, what are the four parameters of PrintHTML function.
It was also asked in
but it wasn't answered...

The first parameter is the filename
The second parameter is the printer
...and I haven't been able to find out the rest two (IF they really exist, it's not certain)!
It *may* be impossible to do it with printto/PrintHTML.

As reported in this link,
the only way to print without a dialog is by sending the following command to a webbrowser control:

Here's some code to get to started (C#, but no big differences from C++)
david_johnsAuthor Commented:
This is actually how I currently perform the task.  I was hoping for a lighter way of doing it, but perhaps it isn't possible.
Here check that link:

The author posted a batch file (version 2) which ought to supress the popup dialog ...

Regards, Alex

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

david_johnsAuthor Commented:

Great lead.  The only thing I don't like about his approach is his use of this 'Kix' utility to do all the work.  Is there a way too use VBScript to do the same thing?  I know VBA has a 'SendKeys' function too.  Anyone know if this is available in VBA?

david_johnsAuthor Commented:
Sorry - on the last line I meant anyone know if this is available in VBScript.
david_johnsAuthor Commented:

Thanks for the lead.  I have not had any more time to look into using a VBScript to do the same thing that the Kix utility does, but you certainly gave me a branch to go down to find the solution that works for me.

If anyone comes up with this script I will open a new question and reward them with points too!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.