JSI Tip 8415. How can I set a user's default printer in a batch script?
August 30, 2004
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.
About the Author
You May Also Like