• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How can I automatically push a printer to people?

Punkrulz

Somewhat eXPerienced
#1
There's always something new!!!

On one of the computers that I had recently setup, there are going to be about 7 or so people who use the computer. Now this never used to be a problem with printers, because I was directly attaching them via IP address. However, I have now started installing the printer on the server, and sharing it out that way. It's easier to find the printer and add it, while not having to get the drivers.

The problem though is while now I'm adding it as the Administrator, it's not applying to all users who login to the computer. Right now it seems that I am going to have to login to each account again, add the printer, sign off, and change the password again... that is just a time guzzler.

What is the easiest way for me to be able to install a printer on a computer, and make it available to the people who login to that printer, whether it's based on the computer itself, or a group that they're in???
 

Punkrulz

Somewhat eXPerienced
#3
Hmm, that will definitely take some getting used to. If I put the line that's listed in that document in the batch file, can I only use that line and nothing else, or do I need to have other lines in it to make it work? Not the best at batch files...

What about VBScript, would VBScript be a better way to do it compared to a batch file?

And yeah, I found out about it the hard way that when you add it directly it adds to all users, and by server it won't... I'm beginning to reconsider this. It's great if there's typically one user who uses a computer, but if there are a few users moving back and forth it might pose problems... I guess that's where the batch / scripts would come into play no?
 
#4
I'm beginning to reconsider this. It's great if there's typically one user who uses a computer, but if there are a few users moving back and forth it might pose problems... I guess that's where the batch / scripts would come into play no?
correct

i have never used login scripts to install printers. I googled and found you that website. Maybe you have a test PC you can try the script on first to see how it preforms.

If I put the line that's listed in that document in the batch file, can I only use that line and nothing else, or do I need to have other lines in it to make it work? Not the best at batch files...
You can add as much stuff as you want in a login script. You may want to add a "pause" statement at the end of your script, when you are testing, so you can see if any error messages come up.
 

fitz

Woah.. I'm still here?
Staff member
Political User
#5
you can use login scripts to install printers.. if your location is small enough and you just want to install the same printers to all users at all locations, then the vbscript portion of it is pretty easy.

Code:
dim strPtrPath
dim objNetwork

strPtrPath = "\\servername\printershare"

set objNetwork = CreateObject("Wscript.Network")
objNetwork.AddWindowsPrinterConnection strPtrPath
set objNetwork = nothing
We use our login scripts to connect printers based on location which is a little more challenging.
 

Punkrulz

Somewhat eXPerienced
#6
Thanks for the script Fitz! Well I'm debating on how to do it. Right now we really don't have any users broken up into specific OU's in Active Directory. I don't see a problem though if I move them to their OU's (in my case, Council right now), and then create that script and apply the printer.

What do I have to change in that script, just the line that says the printer share?

What do I do if I want to add multiple printers to that script?
 

fitz

Woah.. I'm still here?
Staff member
Political User
#7
You just need to change the strPtrPath to the path to your printer.

If you have multiple printers, you could ditch the variable (strPtrPath) and just manually add a line to each printer..
Code:
objNetwork.AddWindowsPrinterConnection "\\server\printer1"
objNetwork.AddWindowsPrinterConnection "\\server\printer2"
You also may want to set the default printer once it's connected
Code:
objNetwork.SetDefaultPrinter "\\server\defaultprintername"
If you really want to get fancy, you can look at using the prnadmin.dll which lets you do a lot more in terms of setting up printers but is a little more work to use (not the least of which is the need to copy the prnadmin.dll file locally to each client and register it with regsvr32.exe. If you want to look at using prnadmin, follow the Microsoft path
 

Punkrulz

Somewhat eXPerienced
#8
Thanks for your quick response!

I had already implemented your script into a vbscript, called it Council Printer. I moved all of the Council users to the Council to the newly created Council OU, and then applied the script using gpmc.msc to the Council OU. I am logged in as one of the council members now and it appears the printer was applied no problem.

I was going to ask about the default printer situation, but you have just addressed that which I greatly appreciate it.

I listed all of the steps that I took so that you could look at them and give me some advice. Do you think the approach I took is the best way to handle it? I don't see a problem breaking up the users into their specific OU's based on department, that's easy enough.

Also, how do you know that a script is either a computer script, or a user script? The script that you have given me, I applied to users... that's just what I felt was supposed to be the case.
 

Punkrulz

Somewhat eXPerienced
#9
Also, now I am getting an error message about line 5 character 1, object missing or something... here is my script:
Code:
dim strPtrPath
dim objNetwork
 
strPtrPath = "[URL="file://\\controler\clerks3500"]\\controler\clerks3500[/URL]"
 
objNetwork.SetDefaultPrinter "[URL="file://\\controler\clerks3500"]\\controler\clerks3500[/URL]"
set objNetwork = CreateObject("Wscript.Network")
objNetwork.AddWindowsPrinterConnection strPtrPath
set objNetwork = nothing
 

fitz

Woah.. I'm still here?
Staff member
Political User
#10
your error is because you are trying to use the network object before you create it (the objNetwork) needs to be created before you can use it.

Also, you can't set the default printer to a printer that doesn't exist. If the user hasn't mapped the printer yet, the script will error out when trying to set the default printer.

The script I wrote out should be consider more of a "scriplett" as in a framework for you to build off of - I didn't include any checks and such (like, if the user already has the printer conencted, do you really need to remap it?) if you don't know much about scripting, I would advise trawling the internet and/or picking up a good book or two on scripting.

All that being said..
Code:
option explicit

'declare my variables
dim strPtrPath
dim objNetwork,objPtrList
dim bolPtrTrue
 
'set the network path to the printer
strPtrPath = "\\controler\clerks3500"
 
'Instantiate my network object
set objNetwork = CreateObject("Wscript.Network")

'Enumerate my current printers 
set objPtrList = objNetwork.EnumPrinterConnections

'Search through my list of current printers
for i = 0 to objPtrList.Count - 1 step 2
   'if I find the printer that I'm trying to connect, set my boolean variable to true
   if objPtrList.Item(intCount+1)=strPtrPath then bolPtrFound = true
next

'if the printer is not currently connected, the connect the printer and set it as the default printer
if bolPtrFound <> true then
   objNetwork.AddWindowsPrinterConnection strPtrPath
   objNetwork.SetDefaultPrinter "\\controler\clerks3500"
end if

set objNetwork = nothing
this should work fairly well if you are only mapping one printer and want it to be the default printer. If you are wanting to map multiple printers, you will need to change it around.. you could move the enumeration of printers into a function and/or maybe read it into an array and search the array to see if the printer exists.

edit: added comments to the code
----
disclaimer:
I did not test this script yet as I usually do before posting a script up here.. I cannot be held responsible for any typos or mistakes. It is a quick and dirty script I wrote up directly here.
:)
 
Last edited:

Punkrulz

Somewhat eXPerienced
#11
Thanks Fitz, I implemented the script but I haven't had the chance to try it. I will give it a shot tomorrow when I am at the client!
 

Ron Bennett

OSNN One Post Wonder
#12
For my point of view desktop management tools are always a good way to remove such kind of pain. Personally I prefer Desktop Authority. It allows do that selectively what's very helpful for configuring users with needed printers throughout the office. Say users that sit in different rooms or floors get that printer that is located close to them.
 
#13
What about over a domain?

I have 9 computers, and users sometimes sit at different terminals. I have two shared printers I'd like to automatically add to all users who log in to the PCs. We already have a login script from IT Services but since the group policy does not permit me to do login scripts I am confused as to how this might work.

I'd like to just set it up so any user who logs in through our domain will automatically get the printer installed - even if they havent already logged in and created a user profile.

I used to use a .bat that used rundll32 but I had to physically sit down and install on each PC for every domain user.
 

rushm001

In the beginning......
Political User
#14
If you install the printer as a "local" printer, but have the printer port set as the network path to the actual printer it will be installed for all users.
 

Attachments

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,240
Members
89,018
Latest member
timpage