Menü schliessen
Created: December 14th 2011
Last updated: May 1st 2020
Categories: Windows 7,  Windows Server 2008 (R2),  Windows XP
Author: Marcus Fleuti

Set default printer on a Windows XP / Windows 7 client via command shell batch file

The goal: In a Windows Client-/Server environment you will most probably want to connect printers via logon script(s) and thus be able to assign dedicated printers to clients automatically.
Shell command for defining a default printer:

rundll32 printui.dll,PrintUIEntry /y /n PRINTERNAME

Hint: The printer name equals to the full name of the printer that was assigned in the control panel->printers. Perhaps you'll need to set this name in between of two ".
In order to assign a network printer to a client use the whole UNC path to that printer as PRINTERNAME

rundll32 printui.dll,PrintUIEntry /y /n \\PRINTSERVER\DRUCKERNAME

This might be useful if you want to connect alternative printers for different users:

@echo off IF %USERNAME%==USER1 ( rundll32 printui.dll,PrintUIEntry /y /n PRINTER1  ) IF %USERNAME%==USER2 ( rundll32 printui.dll,PrintUIEntry /y /n PRINTER2 )