Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print HTML file with mshtml.dll 1

Status
Not open for further replies.

artheim

Programmer
Jan 15, 2003
103
US
I have a Rexx program that builds an html file to be printed and it used to work with the command rundll32 mshtml.dll,PrintHTML C:\path\file.html but since one of the IE updates (don't know exactly where) it no longer works. I can manually open the file with IE and print it that way, but calling mshtml.dll to cause it to print directly does not. Has the syntax of this command changed? Thanks,
 
I found the answer.. I now need to enclose the file name within double quotes and when so doing, it works again.. I would be interested in knowing if there is any reference document that shows the options available from the command line interface tho.. thanks,
 
I am not certain what reference document you are seeking. the "printto:" portion of any file extension is documented by looking at the properties of the extension in Folders, File Type, <extension>, Advanced. (for .HTM):

print: rundll32.exe C:\WINNT\system32 mshtml.dll,PrintHTML "%1"

printto: rundll32.exe C:\WINNT\system32\mshtml.dll,PrintHTML "%1" "%2"
"%3" "%4"

The native print and printto services do not depend on DDE and are referenced by default in the Registry as follows:

[HKEY CLASSES ROOT\.htm]
@="htmlfile"
"Content Type"="text/html"

<scroll to the printto definition>

[HKEY CLASSES ROOT\htmlfile\shell\printto]
[HKEY CLASSES ROOT\htmlfile\shell\printto\command]
@="rundll32.exe C:\\WINDOWS\\SYSTEM\\MSHTML.DLL,PrintHTML \"%1\" \"%2\" \"%3\" \"%4\""

This web site focuses on Rundll32 command lines:
 
artheim,

There are some hidden gems in the command line, especially Rundll32.

If one can have a favorite, mine would be PrintUI.dll as discussed in some useful detail in this thread: thread779-581142

 
bcastner,
Wow! that is some useful command.. without trying, I assume you would first have to install the proper printer drivers on each systems that you are going to add network access with PrintUI.dll? I have a project where I will need to add print support for around 10 different inkjet printers to 35 different systems - was hoping to avoid needing to add each printer to each system due to needing to setup the drivers needed.
 
XP has some ways of helping you with the drivers issue.

. If you setup a network printer, under XP you can preload drivers for non-XP versions of Windows (It is under the properties tab, Sharing).

. use Explorer and go to \Windows\System32 and sort the entries by file type. Scroll down to the VBS entries. Look at all the ones that begin with "p". For example, on "p" VBS that is native to XP is that you can "push" driver sets to XP and non-XP computers with the script prndrvr.vbs:

Prndrvr.vbs

Adds, deletes, and lists printer drivers. Used without parameters, prndrvr.vbs displays command-line help for the prndrvr.vbs command.

To install a printer driver

Syntax
cscript prndrvr.vbs -a [-m DriverName] [-v {0 | 1 | 2 | 3}] [-e Environment] [-s RemoteComputer] [-h Path] [-i FileName.inf] [-u UserName -w Password]

Parameters
-a
Required. Specifies that you want to install a driver.
-m DriverName
Specifies, by name, the driver you want to install. Drivers are often named for the model of printer they support. See the printer documentation for more information.
-v {0 | 1 | 2 | 3}
Specifies the version of the driver you want to install. See the description of the -e Environment parameter for information on which versions are available for which environment. If you do not specify a version, the version of the driver appropriate for the version of Windows running on the computer on which you are installing the driver is installed.

. Version 0 supports Windows 95, Windows 98, and Windows Millennium Edition.
. Version 1 supports Windows NT 3.51.
. Version 2 supports Windows NT 4.0.
. Version 3 supports Windows XP and Windows 2000.

-e Environment
Specifies the environment for the driver you want to install. If you do not specify an environment, the environment of the computer on which you are installing the driver is used. The following table lists the driver environments that are available and the versions that are available for each. Environment Available versions
"Windows NT x86" 1, 2, and 3
"Windows NT Alpha_AXP" 1 and 2
"Windows IA64" 3
"Windows NT R4000" 1
"Windows NT PowerPC" 1
"Windows 4.0" 0

-s RemoteComputer
Specifies the remote computer on which you want to install the driver. If you do not specify a computer, the driver is installed on the local computer.
-h Path
Specifies the path to the driver file. If you do not specify a path, the path to the location from which Windows was installed is used.
-i FileName.inf
Specifies the file name for the driver you want to install. If you do not specify a file name, ntprint.inf is used.
-u UserName -w Password
Specifies an account with permissions to connect by using Windows Management Instrumentation (WMI) services to the computer on which you want to install the driver. All members of the Administrators group for that computer have these permissions, but the permissions can also be granted to other users. If you do not specify an account, you must be logged on under an account with these permissions for the command to work. For more information on WMI, see Related Topics.
/?
Displays help at the command prompt.
Remarks
This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.
If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").

Example
To add version 3 of the printer driver named "Color Printer Driver 1" to the local computer, which offers a Windows NT x86-based environment, type:

cscript prndrvr.vbs -a -m "Color Printer Driver 1" -v 3 -e "Windows NT x86"

. if you point at an installed network printer, it will try and get the printer driver from that printer server machine. This is the default behavior of XP.

. The "g" option in printui.dll offers other possibilities. See Bruce Sanderson's discussion:
. Finally, both the Win2k and Windows2003 Resource Kits offer additional printer utilities. Cleanspl.exe is a favorite of mine and works perfectly under Windows 2k and XP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top