Tag Archives: Printer Management

How to configure and managing network printer on windows server and clients.

Network Printer Management from Command Prompt

rundll32 printui.dll,PrintUIEntry

printui.dll is an library for automated printer configuration tasks with features used by the printer configuration dialog boxes. These features can also be called from a script or command-line batch file, or run interactively through the command prompt.

printui.dll runs with rundll32.exe to provide tools for demanding tasks, add printers, manage, delete, and add network printer connection.

Open printer server properties

Printer server properties open rundll32 printui.dll,PrintUIEntry /s
Open properties of printer server
Properties of Printer Server Section Drivers

Connect to the network printer:

rundll32.exe printui.dll,PrintUIEntry /in /n \\server\LaserJet

The LaserJet network printer which is shared on the SERVER, is installed on the client computer and connected to the server.

Setup printer using driver INF-file:

rundll32 printui.dll,PrintUIEntry /if /b "AddressLabel" /f C:\Driver\Zebra\ZBRN\ZBRN.inf /r "" /m "ZDesigner GK420t" /Z

/if Installs printer using the specified INF-file
/b Basic printer name AddressLabel
/f Path to the printer driver INF-file
/r Portname or IP address
/m Model name of the printer driver from the INF-file
/Z Share this printer, use only with option “/if”

Delete local printer driver:

rundll32 printui.dll,PrintUIEntry /dd /m "LaserJet" /q

/dd Deletes the local printer driver
/m Model name of the printer driver
/q Do not display possible error messages

Delete network printer connection:

rundll32 printui.dll,PrintUIEntry /dn /n "LaserJet" /q

/dn Deletes the network printer connection.
/n The name of the printer.

  Help on printui.dll is get with the following command in the command prompt.

rundll32 printui.dll,PrintUIEntry /?

Batch example:

Example add network printer connection use from Loginscript.

@echo off
@REM Batch Network printer connection
if /i %computername:~0,2%==BE goto Bern 
if /i %computername:~0,2%==BS goto Basel
if /i %computername:~0,7%==SPECTRE goto LAPTOP
goto END
@REM Network printer connection Bern
rundll32 printui.dll,PrintUIEntry /in /n \\SERVER\LaserJet_BE
goto END
@REM Network printer connection Basel
rundll32 printui.dll,PrintUIEntry /in /n \\SERVER\LaserJet_BS
goto END
@REM Network printer connection SPECTRE
rundll32 printui.dll,PrintUIEntry /in /n \\SERVER\OfficeJet_HO
goto END

Operation failed with error 0x00004005

Connect to Printer: Windows cannot connect to the printer. Operation failed with error 0x00004005

Windows cannot connect to the printer
If the error occurs when adding a network printer; Printer connection cannot be established, then the printer driver must be added directly without using the printer setup wizard.
  1. Click on the Start button, and choose settings.
  2. then select Devices and Printers & scanners.
  3. In the Printers window, click on the right to Print server properties, see below Related settings.
  4. choose the tap Drivers.
Windows-Logo + R

Alternatively open the old windows 7 control panel. Right click on the Start button und choose Run, or press Win+R

Windows-Logo + Run and type in control printers

Type in control printers and click OK

Quick shortcut rundll32 printui.dll,PrintUIEntry /s /t2

print server properties
Go through the steps 1 to 3, but first select any printer so that the option Print server properties becomes active.

Now drivers for the appropriate printer can be added with click to the Add button, in the wizard with choose the path to the previously downloaded and decompressed driver package, it must point to the directory in which the printer description INF file is located, or select your printer from the device list for which Microsoft provides certified printer drivers.

How to Adding Network Printer

When using Windows printer shares on a server, errors may occur when adding a network printer on client site, because the printer setup wizard are unable to find the printer driver. The wizard looks for a driver in the InfPath registry key, in which the directory path to the printer driver should be saved.

Path to Printer Drivers in Registry InfPath

Registry InfPath printer connection cannot be established
HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64-Drivers\Version-3

Now that the path to the printer driver is no longer valid, the path must be find in the registry of the server, here in this example it is the printer Sharp MX-C401 PCL6, which includes the path to the printer driver with the INF file in the InfPath registry key, the path shown as follows:


The path is inserted as a value in the InfPath key which is presumably empty, require admin rights to change, run regedit.exe as administrator or temporarily grant admin rights to the user.

  If there is another printer on the client with the same driver, InfPath can copy this value and insert it by double-clicking InfPath on the printer with an invalid value or where the value is empty.

Adding Network Printer manually

Now open the windows administrative share print$ to the print server on the client, where the printer drivers of the server are located.

Share print on server02

i.e. \\SERVER02\print$

Under the print share the printer drivers of the installed printers are located on the print server. In our example \\SERVER02\x64\PCC printer drivers are for the Windows 64 Bit system architecture.

Find the appropriate CAB archive file which has the same driver that is file name as the file in RegistryKey InfPath, so here sn0emdeu.inf.

CAB Archive File

Unzip the compressed CAB archive file that matches the printer from the print- share with 7-Zip, and copy the files to the path taken from InfPath.

DriverStore FileRepository

Connecting and adding network printers is now possible as usual.

  Another simple solution is to add a new printer where by selecting LPT1 as the port, even if LPT1 does not exist, it is re-entered correctly when the path is installed in the InfPath registry key, so that the printer connection to network printers works again, the previously installed printer on LPT1 can be deleted with Device Removal.