Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing to shared printers on a Windows 2003 Server from XP Clients.

Status
Not open for further replies.

milfordboy

Programmer
Dec 13, 2005
23
GB
I've got my HP Laserjet Printers set up on my Windows 2003 Server. They print direct to my HP JetDirect Ports.

I have tried to install my XP clients so they print to the Server - then get directed to the Printer.

When I install my printer as the domain administrator - they dissapear when a user logs on.

Help Please!!!!

I would prefer to install the printers manually that to do it remote. I'd appreciate any suggestions though even if it is remotely or through Active Directory.
 
Take a look here for information on mapping shared printers at logon via VB script its easy to setup and admin once you get the hang.


For a more comprehensive logon script that will map drives as well take a look here.

faq329-5798

The code really can be as easy as

WSHNetwork.AddWindowsPrinterConnection "\\Server\HP5si"
 
Thanks for the info.

Ideally I want to set up the printer manually - rather than doing it as a part of a script.

Is there a way of going to the machine and setting up a printer (which points to the share on the server) and allowing all users to log on to see it?

It is in a school so I don;t want to add to the students logon script - as they can log on to computers all over the school......they don't stick to the same computer all the time.
 
Are your computers named by location?

I've setup several collages printing and it can be managed easily using scripts. The script below will look at the first three characters of the PC name and map the appropriate printer for that location.

Code:
Set Network = CreateObject("Wscript.Network") 
compname = network.computername
room = left(compname,3)
   
Select Case room
      	Case "IT1"
		Network.AddWindowsPrinterConnection "\\server1\IT1Laser" 
		Network.SetDefaultPrinter "\\server1\IT2Laser" 

	 Case "IT2"
		Network.AddWindowsPrinterConnection "\\server1\D28Laser" 
		Network.SetDefaultPrinter "\\server1\D28Laser" 


case else
 
End Select

I'm pretty sure that network printers are added by session so that's why they don't appear when you log on as a different user.
 
You might want too take a look under the 'Local Printers' section of the following link also CON2PRT is a util that might interest you.



If your network has more that 50 PC's tho i would suggest looking at the VB scripts it will save time in the long run.
 
My PC's aren't named by room but I was considering doing that.

So in your script I'm guessting all the computer names start with IT1 or IT2 - so for example it would map a computer called IT1-001 to \\server1\IT1Laser - and map computer called IT2 to \\server1\D28Laser.

Will the printer name show on the local computer be it1laser or will it show the full name - i.e. HP LaserJet 5000GN??


I'm guessing I can add more and more "Case" statements to accomodate all my rooms? (There are 150 clients!)
 
Yes thats it exactly my PC's would be IT1_001 - 030 and so on, i've setup networks with over 50 locations and it works great. You can give the printer a name or just let it pick up the share name. If i share a printer as IT1Laser that is what will show when a user looks at the printer.

The great thing about this is that it uses the WSH so everything you need should already be on the windows clients. Any changes you need to make to printers only need changing in one location so administration is easy.
 
You could always map the printers by where the computer is located in AD...

Code:
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1
'
' NAME: PrinterByOU.vbs
'
' AUTHOR: Paul Chapman , Halcyon Dreams
' DATE  : 2-4-2006
'
' COMMENT: Map Printers based on the computer's location in AD.
'
'==========================================================================

Dim strOU, arrDN

' Get the DN of the computer
arrDN = Split(GetDN, ",")
' DN will look like: CN=computername,OU=yoursubou,OU=yourou,DC=domain,DC=tld

' Strip the OU section out of the array and make it a string
strOU = GetOU(arrDN)

' Map printers based on OU string (all capital letters)
Select Case strOU
	Case "OU=YOURSUBOU,OU=YOUROU"
		wshNetwork.AddWindowsPrinterConnection "\\server\printer1"
		wshNetwork.AddWindowsPrinterConnection "\\server\printer2"
		wshNetwork.AddWindowsPrinterConnection "\\server\printer3"
End Select

Function GetDN()
' Use the NameTranslate object to convert the NT name of the computer to
' the Distinguished name required for the LDAP provider. Computer names
' must end with "$". Returns comma delimited string to calling code.
	Dim objTrans, objDomain, objNetwork

	Set objNetwork = CreateObject("WScript.Network")

	' Constants for the NameTranslate object.
	Const ADS_NAME_INITTYPE_GC = 3
	Const ADS_NAME_TYPE_NT4 = 3
	Const ADS_NAME_TYPE_1779 = 1

	Set objTrans = CreateObject("NameTranslate")
	Set objDomain = getObject("LDAP://rootDse")
	objTrans.Init ADS_NAME_INITTYPE_GC, ""
	objTrans.Set ADS_NAME_TYPE_NT4, objNetwork.UserDomain & "\" _
	& objNetwork.ComputerName & "$"
	GetDN = objTrans.Get(ADS_NAME_TYPE_1779)
	'Set DN to upper Case
	GetDN = UCase(GetDN)
End Function

Function GetOU(DN)
' Select OU's from arrComputerDN and concatenates them using comma
' as a delimiter
	Dim Counter
	For Each Counter in DN
		If Left(arrSplitDN(Counter),3) = "OU=" Then
			If GetOU = "" Then
				GetOU = DN(Counter)
			Else
				GetOU = GetOU & "," & DN(Counter)
			End If
		End If
	Next
End Function


PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top