printuientry

  • Thread starter Thread starter panda
  • Start date Start date
P

panda

I am trying to add set a printer as default using the following
command...

RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /in /n "printer" /c\\computer

the complication is that the printer already exists on this computer,
it is using a local port , but is physically attached to a different
network computer.

so my questions are;

do i need to included the name of the computer that the printer is
attached to, or can i just use the printers sharename.

is the syntax of the command correct?

is there any reason why this shouldnt work when set as a startup
script on the computer?

(e-mail address removed)
 
1. "Default printer" is a per user setting, not a per computer setting, so
it may not make sense to set it in a "startup" script (as opposed to a
"logon" script).

2. I've tried several variations on the command syntax and can not get it to
work remotely. When the command is run locally (to take action on the same
computer that the command is initiated from), there is no need to use the /c
parameter.

3. the syntax that works for the currently logged on user locally is:

rundll32 printui,PrintUIEntry /y /n printername

where printername is the name that is on the General tab of the printer's
properties. If this name has spaces in it, enclose printername in double
quotes ("printername").

4. the /in function is for adding a network printer connection. If the
printer is already defined on a "local port", then the printer (although it
is actually physically connected to another computer), is, by definition, a
Local Printer. True Network Printers do not have local ports. See :port"
and "printer" at http://members.shaw.ca/bsanders/Glossary.htm.
 
I have just remebered one problem I had, when I tried running this, an error
message appeared saying that the printer was no longer on the server. This
was true whether the batch file was run as a logon script or as the user
when logged on. The error did not occur as a network administrator. I tried
making the user a local administrator with no luck. do they also need to be
administrator on the machine with the printer? is there another permission I
am missing? This was the reason I was trying to set permission for everyone
using a system logon.

Thanks

Panda
 
That message is sort a generic message that is the response to most failures
of PrintUIEntry. It tries to give you a hint about what might be wrong, but
does not necessarily identify what actually is wrong.

My test show that an ordinary user can use the "rundll32
printui,PrintUIEntry /y /n printername" command successfully, so presumably
you could put it into a logon script. Most of the other available functions
(including /in) require the user to be an administrator on the targeted
computer. The /y function (set default printer) will fail (with the message
you describe) if the named printer does not exist (e.g. name spelt wrong).

Actions taken on the print client computer (e.g. /y - set default printer or
/ga - add a printer for all users - see
http://members.shaw.ca/bsanders/NetPrinterAllUsers.htm) do not require
administrative rights and permissions on the print server computer ("the
machine with the printer").
 
When im logged on as network administrator, the batch (following) runs
correctly, however when on as a power use it does not work.

rundll32 printui,PrintUIEntry /y /n "\\stationname\printersharename"

this suggest to me that it is a permissions issue

panda
 
Perhaps we are having a terminology or other confusion.

1. If the printer was created with a "Local Port", it will show up in the
(Power) User's Printers and Faxes folder with a single part name (e.g.
printername).

2. If the printer was created as a "Network Printer", it will show up in the
(Power) User's Printers and Faxes folder with a two part name (e.g.
printername on server name).

To set the default printer as a printer of type 1:

rundll32 printui,PrintUIEntry /y /n printername

To set the default printer as a printer of type 2:

rundll32 printui,PrintUIEntry /y /n \\servername\printername

To test this out:

1. logon as an administrator
2. start the Add Printer wizard (you are probably familiar with this, but
I've provided details so we can be sure we are talking apples and not
oranges here)
a. on the Local or Network panel, select "Local Printer", remove check
mark from "Automatically detect ..."; click Next
b. select the "Create a new port" radio button
c. select "Local Port" from the drop down list box; click Next
d. in the "Enter a port name" text box, key the UNC name of the printer
(e.g. \\servername\printername)
e. on the "Install Printer Software" panel, select the appropriate
driver; click Next
f. on the "Name your Printer" panel, in the "Printer Name" text box,
key something unique (e.g. printernamelocal); click Next
g. on the "Printer Sharing" panel, select the "Do not share this
printer" radio button
h. on the "Print Test Page" panel, select "Yes"; click Next
i. click Finish
verify that the Test Page printed
3. open a command prompt and issue the commands:

rundll32 printui,PrintUIEntry /ga /n \\servername\printername
net stop spooler
net start spooler

4. logoff
5. logon with a user account that is a "User" or "Power User"
6. open Printers (or Printers and Faxes) - both printers should show up
(e.g. printernamelocal and printername on servername); right click on each
printer in turn, select Properties and print a Test Page. Verify that both
print OK.
7. in the Printers folder, right click on "printername on servername" and
select it as the default printer (this is just so we know the starting
state)
8. open a Command Prompt window
9. key the command

rundll32 printui,PrintUIEntry /y /n printernamelocal
observe that in the Printers folder this printer immediately becomes the
default printer

10. key the command
rundll32 printui,PrintUIEntry /y /n \\servername\printername
observe that the "printername on servername" immediately becomes the default
printer

I tested this scenario on a computer that is not in a domain and also on a
computer that is a member of a Windows 2000 domain and it worked just fine
in both situations for "Users" and "Power Users".

If this scenario fails for you, please say which numbered step it fails at
and exactly what the symptom is (error message etc.).
 
Firstly, Thanks for all your help!

It fails at stage 10 / 11 ( I tried both for completness)

when failing at stage 10 it says

Printer rundll command failed.
Command: /y /n localprinter. You either entered a printer name that
was incorrect or the specified printer is no longer connected to the
server. Click help for more information.

when at stage 11

Printer rundll command failed.
command /y /n \\servername\printername. operation could not be
completed.

another thing i have noticed is that the administrator now also has
the printer set up as a network printer - I have removed it and
restarted the machine, and it returns. this is in addition to the
version of it mapped locally.

many thanks
 
dear bruce,

cheers for all your help,

i eventually solved my problem by entering the registry and copying the key
from the administrator(ie current user) to the default (users) user....

thanks
 
Back
Top