Link to home
Create AccountLog in
Avatar of MCSComputersServices
MCSComputersServices

asked on

Automatically add printers to computers when they join domain.

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?
ASKER CERTIFIED SOLUTION
Avatar of txhockey26
txhockey26
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
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".
Opps forgot the code.
Set WshNetwork = CreateObject("WScript.Network")
 
WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"
WshNetwork.SetDefaultPrinter "\\PrintServer1\Xerox300"

Open in new window

Avatar of MCSComputersServices
MCSComputersServices

ASKER

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?
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.
How do i do it if i have multiple printers?  Seperate scripts or all in one?  Im not very knowledgable on scripts.
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?
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.
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?
My network is named "AlpineOrthopedic"  I changed the script where is said WSHnetwork to alpineorthopedicnetwork.  Is that right?
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
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

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
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
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

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.
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.
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.
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

Any luck?