Windows

How to add Print Drivers with PowerShell, RUNDLL32, and VBScript in Windows 10

A Printer Driver is a software that your device uses to communicate with a printer on your network. The network printer does not need to have a physical connection to the network and they require an IP address or Simple Network Management Protocol (SNMP) built into CUPS to be discovered. CUPS is a standard-based open-source printing system developed by Apple Inc. for macOS and other UNIX like operating systems. Here are some articles relating to Print Drivers I have written; how to delete obsolete drivers from the Driver Store in Windows 10, how to rename a Printer in Windows 10, how to determine the version and type of a Printer Driver (Printer Driver Information) and how to specify a persistent default printer via the Windows Registry.

To add a printer driver, kindly follow any of the methods discussed below. There are other methods to have drivers installed on Windows 10 and we will be discussing them subsequencly in the future. In this article, I will be using the followng; 
- PowerShell, 
- RUNDLL32and and
- VbScript (PRNDRVR)

This article will be grouped into Part-1 (Drivers present in the Driver Store)
Part 1 – (Drivers Preset in the Driver Store): It is possible to add printer drivers to the Windows driver store (Prestaging). Adding a driver to the Windows driver store does not install the printer driver. It merely adds the printer driver source files to the operating systems for future use such as when connecting to a Printer or having it automatically install during a Plug and Play operation

Method 1 – VBS Scripts to Manage Printers in Windows: These scripts are present in all Windows versions (starting from Vista and Windows Server 2008) and are located in the directory C:\Windows\System32\Printing_Admin_Scripts\en-US.

The following VBS scripts are located in this folder:
 - Prncnfg.vbs – a script to display information about the printer settings;
 - Prndrvr.vbs – printer driver management (install / uninstall printer drivers);
 - Prnjobs.vbs – managing print jobs;
 - Prnmngr.vbs – managing printers (including creating and removing printer in the system);
 - Prnport.vbs – managing connection to the remote printer via TCP/IP ports;
 - Prnqctl.vbs – print queue management;
 - Pubprn.vbs – managing printer publishing in Active Directory - (obsolete)   

Here is an example how to install a printer driver from the Windows driver store using the VBScript prnddrvr.vbs.

cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs" -a -m "HP Type4 Class Driver" -v 3 -e "Windows x64" -i "C:\Windows\inf\ntprint.inf"

Method 2 – Here is an example how to install a printer driver from the Windows driver store using the RUNDLL32.exe.

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /f "C:\Windows\inf\ntprint.inf" /m "HP Type4 Class Driver"

Part 2 – Drivers are not present in the driver store but in a file repository. This command can be used also from the MDT.
Method 1 – VBS Scripts to Manage Printers in Windows (Prndrvr.vbs):.

cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs" -a -m "PCL6_V4_Driver" -v 3 -e "Windows x64" -i "G:\Driver\PCL6_V4_Driver\ntprint.inf"
Parameters
 - a: This parameter tells the VBScript to install the driver
 - m:  The name of the driver you want to install
 - v3: The version of the driver
 - e: Specifies the The environment, i.e, the architecture of the operating system
 - i “path” – the full path to the driver’s INF file. 

Method 2 – Using RUNDLL32.exe: You can also manage Printers Drivers in different versions of Windows via the process rundll32.exe. This receives the name of the library printui.dll and the entry point to it (PrintUIEntry). The command rundll32 printui.dll, PrintUIEntry is enough to perform basic operations with printers and is fully supported by Microsoft. One of the many DLLs that can be loaded is the printui.dll. For more information on how to add printers with no user interaction see this link.

UNDLL32 PRINTUI.DLL,PrintUIEntry /ia /f "G:\Driver\HP Driver\oemsetup.inf" /m "HP Printer Driver"
Parameters
 1: PRINTUI.DLL: This DLL file contains all the functions required to install the printer driver.
 2: /ia: This parameter lets the printui.dll know that a printer driver, using a INF file
 3: /f: The complete path and file name of the INF file of the driver. 
 4: /m: The name of the driver you want to install 

Method 3 – PowerShell: In this session, we will be discussing the various PowerShell commands needed to install, manage, and remove printers, print ports, drivers, and queues using PowerShell. Before proceeding, I will like to discuss some key Pint management cmdlets.

Print Management Module: Below is the cmdlets needed to reveal all the print-server management cmdlets. Here is a list of print, driver, and print queue management cmdlets available in the PrintManagement module on Windows 10. More information on the Print Management Module can be found at this link.

Get-Command –Module PrintManagement

A: Installing a Print Driver available in the Driver Store: You may have to list the print drivers that are installed in the Windows driver store as shown below just to be sure it has not been added previously. Like I said before, there are different ways to go about this. Since we are only discussing how to do this using PowerShell, we will stick to PowerShell only.

Get-PrinterDriver

Note: You can only install a driver with the .inf file only if it is already in the DriverStore. You will notice that it is impossible to install using the" Add-PrinterDriver" command to install a driver that is not available in the system driver storage.

Now, let us install the Print Driver by using the cmdlet below since it is available in the DriverStore .

Add-PrinterDriver -Name "HP Universal Printing" -InfPath "C:\Desktop\HP-Driversx64\hpxxxx.inf"

B: Installing a Print Driver not available in the River Store: If the driver is not available in the Drive Store, kindly use the following steps to add and install your Printer Driver to your device. Add the Printer driver to the Driver Store. You will only be able to install the printer driver if only they are imported to the driver store. This can be achieved with the built-in Windows “pnputil utility”.

Use the add the install switch to the PNPUTIL command to have it installed. To have it installed automatically, we need to add the /i switch and this command can also be executed directly from the MDT task sequence as well "pnputil.exe /a /i G:\Repository Directory\MyINFFile.INF".

pnputil.exe -i -a C:\RepositoryDirectory\xxxxxxx.inf 
This (installs the specific printer driver) or 
pnputil.exe -i -a C:\RepositoryDirectory*.inf 
This installs all the drivers found in the INF files in the specified directory)

Note the following below.
– The /reboot switch can also add this if it is needed to complete the operation.
– Starting with Windows Vista, the Plug and Play (PnP) manager performs driver signature verification during device and driver installation. However, the PnP manager can successfully verify a digital signature only if the following statements are true

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session. I welcome you to follow me on Twitter and Facebook.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x