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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapping Printers in OU's with a GPO 1

Status
Not open for further replies.

andyase

IS-IT--Management
Feb 26, 2004
2
GB
Hi i have a problem, Windows server 2003,
example:
I have two OU's, I have several pc's in each OU, I want to set up a GPO in each OU that runs a start script to map the pc's in each ou to a certain printer from the computer configuation half, so I have the OU, the GPO, startup script pointing to a vb script in netlogon (sysvol,scripts), I have set security on the gpo to a test computer in the ou (read and execute)i can run the vb script locally and it maps the printer, however when i log on to the machine it will not map the printer no messages, i have the default domain gpo running ok, and i have tested another gpo using the user config settings ok, anyone know why this gpo won't work.

TIA
Andy
 
Hi
Yes i managed to solve this using lots of snippits of info from around the web, basically you do this

1.Create an ou
2.Place some pc's in the ou
3.Create a Group policy for the ou, edit the Gp
4.In the computer section - computer/admin/system/group policy "Policy = User group policy loopback proccesing mode" enable and set to merge.
5.In the same Gp In the User section - User/windows settings/scripts logon, create a batch file, and point to it
6.In the batch file type: (path to the batch file and con2prt)
@echo off
\\server\sysvol\domain\con2prt /f
\\server\sysvol\domain\con2prt /c \\server\printername
\\server\sysvol\domain\con2prt /cd \\server\printername

7.get con2prt.exe from the web put in the same folder as the batch file.
8.the /f switch delete's all printers, the /c switch maps the printer and the /cd switch maps a default, you can map several printers if you want, be aware if you want any more printers for groups you need to run a script after this one otherwise the /f will disconnect them, i run a kix script for group printer that runs after this one, this one runs as soon as the user logs on.

Andy
 
Thanks Andy

I've got to go out for a few days but I'll check it ASAP and let you know.
 
I was just looking for something else and found this posting by mistake. I have solved a problem similar to this, but I used a batch file at logon to map printers to the user portion - put a line in filename.bat:

regedit /s \\server\filepath\filename.reg

Then the reg file has the lines:

Windows Registry Editor Version 5.00

regedit4

[HKEY_CURRENT_USER\Printers\Connections\,,SERVERNAME,PrinterSharename]
"Server"="\\\\SERVERNAME"
"Provider"="win32spl.dll"

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices]
"\\\\SERVERNAME\\PrinterSharename"="winspool,Ne07:"


Not a vbs script I know but just thought I would share my twopennyworth as I have used this method to re-assign lots of networked printers when people move offices. I am sure there will be a similar way to add this to the computer config instead.

Hope this helps.
 
Thanks Grunty, but Andy's solution works fine for me and seems a little more elegant than hacking the registry. That said I will try your method, knowledge is power and all that.

Thanks to all you guys who have helped on this, especially to Andy.

Cheers

Jay

PS. Merry Christmas and Happy New Year to All
 
I think I may have something to help you out with the OU script your working on. I developed the script below about a year ago. It uses Ldap to identify the OU a computer is a member of and then calls the OU's name then installs the printer accordingly. In my AD structure I have OU's for each area, R&D, Purchasing, Accounting and I call the OU's then install the printers in that area to the computer in that area. This is just a piece of a larger logon script that maps drives by group membership.

Public Sub Print()

'This routine installs printers based on OU membership
'Some cases may call more than one routine for printer install

Set objAdsSystemInfo = CreateObject("adsysteminfo")
Set objComputerName = Getobject("LDAP://" & objAdsSystemInfo.ComputerName)
Set objOU = GetObject(objComputerName.Parent)
strOU = replace(objOU.Name,"OU=","")

Select Case strOU
Case "Information Technology Area"
Call Print1()

Case "Human Resources Area"
Call Print2()

End Select

End Sub

Sub Print1()
'Information Technology Area
MapPrinter "\\server01\Information Technology DELL 5200 PCL"
MapPrinter "\\server01\Accounting Receivable HP 4100n PS"
MapPrinter "\\server01\Accounting HP 4500 PS Color"
End Sub

Sub Print2()
'Human Resources Area
MapPrinter "\\server01\Customer Service HP 4600 PCL Color"
MapPrinter "\\server01\Human Resources HP 4100mfp PCL"
End Sub


Function MapPrinter(name)

PrinterFlag = False

Set Printers = WSHNetwork.EnumPrinterConnections 'Create printer objects from local host
For a = 0 To Printers.count - 1 'Loop through all printer objects
'WScript.Echo Printers.item(a) 'debug line to verify looping

If name = Printers.item(a) Then 'Check to see if printer is the one we are looking for
PrinterFlag = True 'if so then return true

Exit For 'exit loop
Else
PrinterFlag = False
End if
Next

If PrinterFlag = False Then
WSHNetwork.AddWindowsPrinterConnection name
strStatus = strStatus & vbCRLF & "Mapped " & name
End If

Set Printers = Nothing

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top