Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

default printer

Status
Not open for further replies.

ylancantho

IS-IT--Management
Dec 31, 2005
70
US
I just installed HP LaserJet 4250 printer. How can I make it the default printer for everybody who logs in? This printer is shared by many users. Instead of having the user clicks on setting - printers to set the default printer, how can I set it so they don't have to set the default printer themselves.
 
You should only have to set the default printer once in every user unless someone changes it. Do you have multiple printers that you use? or just this one?

A+ and coming soon: Network +
 
Two methods, both using PrintUIEntry. I will use a network printer as the example, but a locally attached printer works fine:

1. Method #1: PrintUIEntry:

rundll32 printui.dll,PrintUIEntry /ga /n Printer_name /y

Windows 2000, XP and 2003 have the capability to have a Printer so that it is automatically available to any user that logs on at that computer. Unfortunately, the Add Printer wizard does not expose that capability - it can only add a Printer for the currently logged on user. So to add a printer globally (for all users) you have to a different tool.

The PrintUIEntry function of printui.dll has options for performing most printer management functions. It can perform these functions either on the same computer that printui.dll is running on or on another computer (i.e remotely). The general purpose rundll32 command can be used to execute PrintUIEntry function of printui.dll.

Some things to keep in mind:
[ul]
[li]The function for adding a printer globally is /ga. Globally in this context means that the action applies to all and any users that happen to logon at the target computer.[/li]

[li]/c Can be used to specify a remote Computer name[/li]

[li]The corresponding function for deleting a printer globally is /gd. If you attempt to delete a global printer by using the Delete function in the printer's context menu, it will appear to delete, but will reappear when the Print Spooler service is restarted.[/li]

[li]Only printers previously added using the /ga function can be deleted using /gd.[/li]

[li]You have to have administrative rights and permissions on the target computer to use these functions.[/li]

[li]If a printer is added remotely using the /ga function, it will not appear to the user until the Print Spooler service is restarted or the user next logs on. You can restart the print spooler remotely using these commands:
sc \\targetcomputername stop spooler
sc \\targetcomputername start spooler
[/li]
[/ul]
To find out more about the rundll32 printui.dll,PrintUIEntry command, key (case sensitive):

rundll32 printui.dll,PrintUIEntry /?

Here's some details:
[ul]
[li]/c specifies the computer which is to be the target of the requested action.[/li]
[li]If /c is not specified, the local computer is assumed. In other words, the /c option allows you to do printer management things on other computers without actually physically being there (i.e. remotely).[/li]
[li]/n specifies which printer is to be, in this case, added using the printer's UNC name: (\\servername\printersharename)[/li]
[li]/y specifies the printer will be the default[/li]
[/li]? is understood by PrintUIEntry to be a request for its Help information, which is displayed in a separate window.[/li]
[/ul]

The "start /wait" command runs the command (e.g. sc), then waits until the command actually terminates. Stopping and starting the print spooler takes a while, so without this, the next command (e.g. sc ... start spooler) may run before the spooler is actually stopped.

2. Method #2: User Logon Script:

/y makes the printer \\server\printername the default. (Note that the command is done twice.)

rundll32 printui.dll,PrintUIEntry /in /n \\server\printername
rundll32 printui.dll,PrintUIEntry /in /n \\server\printername /y

See:
thread779-581142




____________________________
Users Helping Users
 
You are welcome.

Best,
Bill Castner


____________________________
Users Helping Users
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top