Article ID: 314486 - View products that this article applies to.
This article was previously published under Q314486
For a Microsoft Windows 2000 version of this article, see 189105
Windows XP permits you to install a printer from the command line. This is particularly useful when you use a logon script or a scheduled event to add or remove a printer from a group of users.
Although Microsoft Windows NT 4.0 contains tools such as Con2prt.exe, Con2prt.exe permits you to add or delete only network printers. You can modify and delete local printers by using Windows XP. The result is that an administrator can control all aspects of a user's ability to print by requiring users to run a batch file or logon script.
Note If you use this command in a logon script or a client-based batch file, the client computer must be running Windows XP or Microsoft Windows 2000. Because the logon script runs on the client computer, a Windows NT 4.0 client cannot process the command.
Additionally, these commands can be run from an administrator's workstation or from a server so that the printers are push-installed to the client computers, without having to install from the actual computer.
The following examples list the most typical uses for the Printer User Interface (PrintUIEntry) command.
Note This command runs only on a Windows XP or Windows 2000-based computer; and it can be used only to install a printer on, or remove a printer from, a Windows XP, Windows 2000, or Windows NT 4.0-based server or workstation.
The following example adds an Agfa printer driver and creates a logical printer on a computer named SERVER.
Note Both lines can be placed in a batch file or typed after each other at a command prompt. These two lines are wrapped for readability.
The following example deletes an Agfa printer on a computer named SERVER:
For more information about the available switches, type /? after the command.
Additionally, type the following at a command prompt:
The preceding command displays the full list of usage switches, with extensive examples for using this method.
Note The following sample syntax works correctly as long as the standard TCP/IP ports are created:
If you do not enter the printer name correctly, or if you specify a printer that is not connected to the server, standard TCP/IP ports are not created, and you may receive the following error message:
Printer User Interface
Printer rundll command failed.
Command: /if /b "Test Printer" /f %windir%\inf\ntprint.inf /r "IP_188.8.131.52" /m "HP Laserjet 4000 Series PCL" /Z.
You either entered a printer name that was incorrect or the specified printer is no longer connected to the server. Click Help for more information.
Sample of How to Add an IPP Printer
rundll32 printui.dll,PrintUIEntry /b "DisplayPrinterName on http" /x /n "part of the n switch" /if /f %windir%\inf\ntprint.inf /r "http://hostname/printers/sharename/.printer" /m "HP Laserjet 4000 Series PCL"Note The /x switch is not documented with /?. The /x switch expects /n even though it is not used. Also, you may be using a printer other than the HP Laserjet 4000 Series PCL. The /x flag treats the install as a “Web point and print.” This flag indicates that the printer is a masquerading (masq) printer. A masq printer is partly local printer and partly a network printer. A masq printer receives rich notifications from the remote print server. Without the /x option, the printer is a local printer with a redirected port. It works fine, but it has very limited notifications.
The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.