Manage Windows Printers At The Command Line

Install An IP Printer

This will create a new printer port at the IP address and name it IP_10.10.10.10.

cscript %windir%\system32\printing_admin_scripts\en-us\prnport.vbs -a -r IP_10.10.10.10 -h -o raw -n 9100

Then this will add the printer to that port with the correct driver (found on a network share).

rundll32 printui.dll,PrintUIEntry /u /if /b "MyPrinterName" /f "\\Deployments\PrintDrivers\hp3550\hpc3550w.inf" /r "IP_10.10.10.10" /m "HP Color LaserJet 3550"

Set A Printer As The Default Printer

REM list all printers, pipe results into findstr.exe and searches for the printer name

cscript %windir%\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -l | %windir%\system32\findstr.exe /i ".MyPrinterName."

REM if the command finds a result it sets the default printer. If it finds nothing, the script exits
REM the printer name needs to be exact or it will error out
if %ERRORLEVEL%==0 (rundll32 printui.dll,PrintUIEntry /y /n "MyPrinterName") else (echo exit)