Emulating Local Printing on a Network

Brian St. Marie - Sr. Systems Engineer

Most network administrators and technicians are familiar with mapping a printer from a server.  This is the most typical and efficient way of sharing printers on a network.  However, many applications, especially legacy applications, only work with a local, non-network printer.  Some applications may also require the printer have a specific name, which won't work with network printers as you cannot rename them.  There are a few ways to get around these problems, if an application requires it.

The first, and most straightforward, is simply to manually create a local printer port which actually redirects to the server hosting the printer.  This can be done through the Add Printer Wizard on any version of Windows by simply selecting "Local Printer" and adding a new Local Printer Port.  The name of the port is \\servername\printername.

However, this process requires manually installing the printer on each computer, which can be time consuming and difficult to manage if you're trying to deploy the printer to several machines.

Installing a local printer via script can be done, using the PrintUIEntry function found in Windows XP and onward.  The basic command is:

rundll32 printui.dll,PrintUIEntry /if /b <printername> /f %windir%\inf\ntprint.inf /r <portname> /m <drivername> /u

This will install the printer with the specified name, port, and driver.  However, this script assumes the port name specified already exists, so the port must be created first.  There are two ways to do this.  For computers with old LPT parallel ports, you can map LPT1 to a network location and then specifiy LPT1 in the script.  The script would look something like this:

net use LPT1 \\servername\printername /persistent:yes

rundll32 printui.dll,PrintUIEntry /if /b <printername> /f %windir%\inf\ntprint.inf /r LPT1 /m <drivername> /u

Unfortunately, this will not work if there are no parallel ports on the target computer, as then LPT1 does not exist.  In that case, we need to create a new Local Port on the machines the way we did above in the manual scenario, but this time we need to do it via script.  The best way to do this is by adding a registry entry to the target machine, which creates the port. Then we restart the spooler on the target machine so it recognizes the new port.  The basic script would look like this:

net stop spooler

reg ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Ports" /v \\servername\printername /t REG_SZ /f

net start spooler

rundll32 printui.dll,PrintUIEntry /if /b <printername> /f %windir%\inf\ntprint.inf /r \\servername\printername /m <drivername> /u

The catch with this scenario is that we must have elevated privileges to run this script on Windows Vista or Windows 7.  Otherwise, we will not be allowed to add any info to the registry or restart services via script.

One last method uses new technology released with Windows 2008, call Group Policy Preferences.  GPP allows an administrator to control almost anything they like on the target machines, including adding local printers to an entire domain.  The sets are essentially the same as the manual process above, except done through the GPP interface.  Once configured, GPP will execute on each machine as it starts up on the domain, ensuring the printer is added appropriately.  This is the cleanest and simplest method, but requires Windows 2008 domain controllers and also requires Windows 7 clients.  For Windows Vista or Windows XP, the GPP extensions will first need to be deployed and installed.  However, this is the simplest and most reliable method, once GPP is deployed and working on the network.

There are many solutions to the problem of local printing emulation on a network.  Exactly which method is right for each network depends on many factors and choosing the wrong method can result in extensive headaches and buggy deployment.  Proper research and preparation is necessary before committing to any solution.