Script to add printer

  • Thread starter Thread starter Jeniffer K
  • Start date Start date
J

Jeniffer K

Dear NG, I'm facing the following scenario

I've setup a network in a school that has over 700 students that will all
use the newly created computer labs, we have about 7-8 labs and 2 public
libraries, one of the things I need to accomplish is to simplify the printer
creation process, the problem is that the same user will move around from
lab to lab and of course the public library's we have different printers
setup all over the place, I was thinking of setting up scripts based on the
computer so no mater where the user logs on they will get the correct
printer automatically created for them and set as the default, I have
created a procedure but its not working perhaps one can point me where is
off

I've created a ou called pcslab1
I've moved all the pc's from lab 1 to the above ou
I've created a vb script called addprnt.vbs (see script below) to add the
appropriate printer and set as default
I've created a group policy for the above ou and assigned the addprnt.vbs
logon script

if I double click the script manually it works fine, also no events

here is the script...

Option Explicit
Dim objNetwork, strUNCPrinter
strUNCPrinter = "\\servername\sharename"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strUNCPrinter

objNetwork.SetDefaultPrinter strUNCPrinter
WScript.Echo "Check the Printers folder for : " & strUNCPrinter

WScript.Quit

I'd appreciate any help, thanks in advanced
 
Do the regular users have the rights to install a printer? Anything in the
event logs?

....kurt
 
You can assign printers for all users using a startup script (rather than a
logon script) and rundll32.exe, i.e.

rundll32 printui.dll,PrintUIEntry /q /ga /n \\PrintServer1\Room306

....kurt
 
why should startup scripts work better then logon scripts, do I assign the
startup script to the users OU or machine OU, does this command allow you to
set as default, also I have tried using the rundll32
printui.dll,PrintUIEntry command before but was never successful
 
In fact, I try to avoid mapping drives and printers through startup scripts.
Its unreliable because the normal mode of operation for mappings is to store
them per-user. Yes you can store it per computer, but again I've seen that
behave unreliably in many cases. In this situation what I would do is set up
those lab computers with loopback policy
(http://support.microsoft.com/kb/231287/en-us) and then define your printer
mappings in logon scripts within the loopback policy applied to the
machines.

Darren

--
Darren Mar-Elia
MS-MVP-Windows Server--Group Policy
Check out http://www.gpoguy.com -- The Windows Group Policy Information
Hub:
FAQs, Whitepapers and Utilities for all things Group Policy-related
Just Released! The new Windows Group Policy Guide from Microsoft
Press!!!
Check it out at http://www.microsoft.com/mspress/books/8763.asp
 
This was in case your users didn't have the rights to install printers. A
startup script runs before the user logs on so is not limited by the user's
lack of rights.
Darren makes a good argument for loopback scripts if you want to assign
different printers for the same user when they log onto different machines.
I would be interested to know what "unreliable" issues Darren has had. I
have used this to set up printers without problems, but that doesn't mean I
won't have problems next time. Anyway, this would not assign printers based
on particular users if that's what you needed. If you decide to go with the
loopback GPO in a logon script, the users will still have to have rights to
install a printer I think.

....kurt
 
I have to argue about the rights to install, a user does not need local
rights to connect to a network printer that's published in AD, i'm not
installing a local printer
 
Darren, thanks for your sugesstion, enabling loopback policy did the trick,
i knew im missing somthing it was loopback policy that I totally forget
about - thanks dude
 
You're absolutely right! I just tried it and a user with no special rights
was able to connect to a network printer via a logon script. Don't know
where I missed that one!

Thanks,

....kurt
 
Kurt-
Most of the problems I've seen are with mapping network connections
per-machine and it usually manifests itself as flaky connections. The
connection will be unavailable or won't persist through logons. I have to
admit that I haven't tested it as much on printers so they may fair better
but I generally just avoid it.

--
Darren Mar-Elia
MS-MVP-Windows Server--Group Policy
Check out http://www.gpoguy.com -- The Windows Group Policy Information Hub:
FAQs, Whitepapers and Utilities for all things Group Policy-related
And, the Windows Group Policy Guide is out from Microsoft Press!!! Check it
out at http://www.microsoft.com/mspress/books/8763.asp
GPOGUY Blog: http://blogs.dirteam.com/blogs/gpoguy
 
Back
Top