Solved

Automatically add printers to computers when they join domain.

Posted on 2008-06-17
20
415 Views
Last Modified: 2010-04-18
I am the network administrator for a client running Server 2003. We have about 10 client machines running xp. Is there a way that i can force the client machines to automatically connect to all available domain printers when they join the domain? Or have the server detect a new client and push out all the printers to that client?
0
Comment
Question by:MCSComputersServices
  • 10
  • 9
20 Comments
 
LVL 7

Accepted Solution

by:
txhockey26 earned 500 total points
ID: 21803600
Several ways to accomplish this.   If you would like to use GP and you the server is 2003 R2:
http://www.windowsnetworking.com/articles_tutorials/Deploying-Printers-Group-Policy-Windows-R2.html

For VBScript....Chris-Dent has a quick walk through on here:
http://www.experts-exchange.com/Programming/Languages/Scripting/Q_22390164.html
0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21803620
The only method I know of is using scripts to add printer connections. The script can be either a account based profile script or a Group Policy user logon script.

Below is a sample of a VB script used to add a printer. You can simple modify it to include any printers you want.

Create the script name it was a .vbs file, either place it in the scripts folder or add it in a group policy at"user->Windows-> Scripts->Logon".
0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21803633
Opps forgot the code.
Set WshNetwork = CreateObject("WScript.Network")

 

WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"

WshNetwork.SetDefaultPrinter "\\PrintServer1\Xerox300"

Open in new window

0
 

Author Comment

by:MCSComputersServices
ID: 21805468
So if i copy the script you wrote and just replace your xerox  printer with the one i use, it should work?  Also wondering why you skipped a line?
0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21805618
If you copy that script into a file with the .vbs extension and modify it as you states, yes it should work.

The blank line doesn't affect the script, other than to make it easier to read.
0
 

Author Comment

by:MCSComputersServices
ID: 21807148
How do i do it if i have multiple printers?  Seperate scripts or all in one?  Im not very knowledgable on scripts.
0
 

Author Comment

by:MCSComputersServices
ID: 21807203
Also, i assume they have to be logging into their domain accounts and not to the local computer that is a member of the domain?
0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21807356
That is correct as it would be a user policy.

You can add as many printers as you want simply by adding more of the add printer lines with the different UNC names. Put each one on its own line.
0
 

Author Comment

by:MCSComputersServices
ID: 21807406
I made a script and added it to the logon session of a user. When i logon as that user the printer is still not added? Do i need to publish the printer in group policy?
0
 

Author Comment

by:MCSComputersServices
ID: 21807457
My network is named "AlpineOrthopedic"  I changed the script where is said WSHnetwork to alpineorthopedicnetwork.  Is that right?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 6

Expert Comment

by:raptorjb007
ID: 21807563
You should only be changing the sharename and patch of the printer.

Ie in:
WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"

Only change the path to the printer share. See the code section for a script example that adds three printers and sets the default printer to a printer shared as "HPLJ4250" on a server named "ServerDC1"

The Set WshNetwork = CreateObject("WScript.Network") line is a necessary line for the script to operate, do not change this line.

The "WshNetwork.AddWindowsPrinterConnection "\\ServerDC1\HPLJ4250"" line adds a printer connection.

The WshNetwork.SetDefaultPrinter "\\ServerDC1\HPLJ4250" sets the default printer
0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21807572
Forgot to add the code section again.
Set WshNetwork = CreateObject("WScript.Network")

 

WshNetwork.AddWindowsPrinterConnection "\\ServerDC1\HPLJ4250"

WshNetwork.AddWindowsPrinterConnection "\\ServerDC1\HPLJ4050"

WshNetwork.AddWindowsPrinterConnection "\\ServerDC1\ColorLJ3600"

WshNetwork.SetDefaultPrinter "\\ServerDC1\HPLJ4250"

Open in new window

0
 

Author Comment

by:MCSComputersServices
ID: 21807708
ok, here is my script. For some reason it still doesnt add the printer when the user logs on.
Set WshNetwork = CreateObject("WScript.Network")
 
WshNetwork.AddWindowsPrinterConnection "\\alps\HP Laserjet 1320 PCL 6"
WshNetwork.SetDefaultPrinter "\\alps\HP Laserjet 1320 PCL"

Alps is the name of the DC and HP Laserjet 1320 pcl 6 is the printer
0
 

Author Comment

by:MCSComputersServices
ID: 21807734
I changed the name of the printer to "Nurse Printer"
Here is my new script.

Set WshNetwork = CreateObject("WScript.Network")
 
WshNetwork.AddWindowsPrinterConnection "\\serveralps\NursePrinter"
WshNetwork.SetDefaultPrinter "\\serveralps\NursePrinter"

When i try to run the script, it says printer name invalid
0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21807777
Are you using the name of the printer as it appears in "printers and faxes" or its share name? This script references the share location, so you would need ot utilize the share name(located in the sharing tab of the printer's properties".

Also you don't need to put the word "server" in front of the servername unless that is its actual name.

So if the server is called "ALPS" and the printer's share name is "NursePrinter", use:
WshNetwork.AddWindowsPrinterConnection "\\alps\NursePrinter"

If the server is called "ServerAlps" and the printer share name is "Jumbalya" use:
WshNetwork.AddWindowsPrinterConnection "\\serveralps\jumbalya"

So in your case, I will assume that the server is named "Alps" and the printer share name is "NursePrinter", the script you need would be as follows.


Set WshNetwork = CreateObject("WScript.Network")

 

WshNetwork.AddWindowsPrinterConnection "\\Alps\NursePrinter"

WshNetwork.SetDefaultPrinter "\\Alps\NursePrinter"

Open in new window

0
 

Author Comment

by:MCSComputersServices
ID: 21807864
When you say server, do you mean my DC or the computer that the printer is physically connected too?
I apologize if i am asking stupid questions, i am learning as i go.
0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21808093
By server, I mean the computer which is sharing the printer. The format of a UNC share name is

\\computername\sharename

In this instance, for "computername" use the name of the device that is sharing the printer, and for "sharename" use the share name of the printer as listed in the "sharing" tab of the printer's properties.

I step you through locating this information if needed. Let me know.
0
 

Author Comment

by:MCSComputersServices
ID: 21814905
I am trying to use a different printer this time. The share name of the printer is "recoveryprinter"
It was installed from a computer named gloria even though its installed on a tcp/ip port.
Here is the script.
Set WshNetwork = CreateObject("WScript.Network")
 
WshNetwork.AddWindowsPrinterConnection "\\Alps\recoveryprinter"
WshNetwork.SetDefaultPrinter "\\Alps\recoveryprinter"

I used alps as the server because its on a tcp/ip port. When i try to change the name of the share using the computer named gloria, it says i cant so i assume i need to use the server to do it.
When i try to run the script it says printer name invalid. I know this shouldnt be this hard to make a simple script run.
0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21815043
Since the printer is shared from the computer named Gloria, you need to change the script to connect to gloria not alps..

Now, being a printer connected from a TCP/IP port, you can install he printer directly on Alps using the tcp/ip port and share it as "recoveryprinter" and your script would work. Otherwise you need to change to script to connect to the computer sharing the printer, in this case it seems to be "Gloria"(see below).

Remember, your connecting to a share on a server or pc, the script is simply trying to connect to a share at the location you specify. Your script is trying to connect to alps but recoveryprinter is shared on gloria, as such the printer name is invalid because there is no printer currently shared as "recoveryprinter" on alps.

I hope this helps.


=====Script to connect to printer shared on gloria=======

Set WshNetwork = CreateObject("WScript.Network")
 
WshNetwork.AddWindowsPrinterConnection "\\gloria\recoveryprinter"
WshNetwork.SetDefaultPrinter "\\gloria\recoveryprinter"

=====end=====


=====Script to connect to printer shared on alps=====

Set WshNetwork = CreateObject("WScript.Network")
 
WshNetwork.AddWindowsPrinterConnection "\\Alps\recoveryprinter"
WshNetwork.SetDefaultPrinter "\\Alps\recoveryprinter"

=====End=====


 

Set WshNetwork = CreateObject("WScript.Network")

 

WshNetwork.AddWindowsPrinterConnection "\\gloria\recoveryprinter"

WshNetwork.SetDefaultPrinter "\\gloria\recoveryprinter"

Open in new window

0
 
LVL 6

Expert Comment

by:raptorjb007
ID: 21884379
Any luck?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now