JSI Tip 8415. How can I set a user's default printer in a batch script?

Jerold Schulman

August 30, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today


In tip 0672, you set a users default printer using the registry.

In tip 2014, I introduced rundll32 printui.dll,PrintUIEntry /?

To use the RUNDLL32 PRINTUI.DLL,PrintUIEntry command to set a user's default printer, the syntax is:

RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "Printer Name"

where "Printer Name" can be a local printer or a remote printer.

Examples:

To set a local printer as the logged on user's default:

RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "HP OfficeJet R80xi"

To set a remote printer as the logged on user's default:

RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n"\JSI001.JSIINC.COMHP Business Inkjet 2250 (PCL5C)"

To retrieve the logged on user's default printer from the registry:

for /f "Tokens=2*" %%a in ('REG query "HKCUSoftwareMicrosoftWindows NTCurrentVersionWindows" /V Device^|find "REG_SZ"') do ( set device=%%b)

where REG.EXE is either built-in (Windows XP and Windows Server 2003), or from the Windows 2000 Support Tools on the CD-ROM.



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like