Help asssigning printers at logon

J

Jim Florence

We are nearing the end of an AD rollout and are having problems getting out
printers to be assigned to users during logon.

We use con2prt to map the printers, If you run the script as admin it works
a treat but not for normal users. Any pointers on how to do this greatfully
recieved.

Regards

Jim Florence

P.S. here is the script if anyone finds it useful to either hack for
themselves or troubleshoot.

On Error Resume Next
Dim objShell
Dim WshNetwork
Dim department,department_location
Set objShell = wscript.createObject("wscript.shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")

'ADD ALL THE CONTINGENCY PRINTERS FIRST
'bind_line = "%COMSPEC% /c c:\windows\con2prt.exe /f /c \\rgc-1\adm-r9mono
/c \\rgc-1\adm-r9colour"
bind_line = "con2prt.exe /c \\rgc-1\adm-r9mono /c \\rgc-1\adm-r9colour /c
\\rgc-1\bio-colour"




'Take the first 3 letters of the PC name for comparison
'and then add a printer to the bind_line based on department.
'If the department has more than one printer
'take the next 3 letters of the PC name and allocate
'the printers based on room numbers within the department.

pcname= WshNetwork.ComputerName
department = UCase(Left(pcname, 3))

'Wscript.Echo pcInitial
Select Case department
case "ISD" defprinter="\\rgc-1\isd-base"
case "WEB" defprinter="\\rgc-1\isd-base"
case "COM" defprinter="" 'MULTIPLE DEPT PRINTERS - GOTO NEXT SECTION
case "ENG" defprinter="\\rgc-1\eng-base"
case "MAT" defprinter="\\rgc-1\mat-base"
case "PHY" defprinter="\\rgc-1\phy-base"
case "CHE" defprinter="\\rgc-1\che-base"
case "BIO" defprinter="\\rgc-1\bio-base"
case "LAN" defprinter="\\rgc-1\lan-base"
case "CLA" defprinter="\\rgc-1\cla-base"
case "RED" defprinter="\\rgc-1\re-base"
case "PED" defprinter="\\rgc-1\pe-base"
case "HIS" defprinter="\\rgc-1\his-base"
case "GEO" defprinter="\\rgc-1\geo-base"
case "GUI" defprinter="" 'MULTIPLE DEPT PRINTERS - GOTO NEXT SECTION
case "MUS" defprinter="\\rgc-1\mus-base"
case "ADM" defprinter="" 'MULTIPLE DEPT PRINTERS - GOTO NEXT SECTION
case "SMT" defprinter="" 'MULTIPLE DEPT PRINTERS - GOTO NEXT SECTION
case "LIB" defprinter="\\rgc-1\library"
case "TEC" defprinter="" 'MULTIPLE DEPT PRINTERS - GOTO NEXT SECTION
case "BUS" defprinter="" 'MULTIPLE DEPT PRINTERS - GOTO NEXT SECTION
case "BLA" defprinter="\\rgc-1\bla-tutorial"
case "JUN" defprinter="" 'MULTIPLE DEPT PRINTERS - GOTO NEXT SECTION
case "ART" defprinter="\\rgc-1\art-base"
case "LSP" defprinter="" 'MULTIPLE DEPT PRINTERS - GOTO NEXT SECTION
End Select

if NOT defprinter="" THEN

bind_line = bind_line & " /cd " & defprinter

'wscript.echo bind_line
' WSHNetwork.AddWindowsPrinterConnection defprinter
' objShell.Run("%COMSPEC% \\rgc-2\data\printutils\con2prt.exe /cd " &
defprinter)
' WSHNetwork.SetDefaultPrinter defprinter
ELSE
department_location = UCase(Mid(pcname, 5,3))

if department = "COM" then
printer1 = "\\rgc-1\com-t2"
printer2 = "\\rgc-1\com-t3"
printer3 = "\\rgc-1\com-t4"

Select Case department_location
case "T02" defprinter=printer1
case "T03" defprinter=printer2
case "T04" defprinter=printer3
End Select

bind_line = bind_line & " /cd " & defprinter

END IF


' if department = "GUI" then
' printer1 = "\\rgc-1\com-t2"
' printer2 = "\\rgc-1\com-t3"
' printer3 = "\\rgc-1\com-t4"
'
' Select Case department_location
' case "t02" defprinter=printer1
' case "t03" defprinter=printer2
' case "t04" defprinter=printer3
' End Select
'
' WSHNetwork.AddWindowsPrinterConnection printer1
' WSHNetwork.AddWindowsPrinterConnection printer2
' WSHNetwork.AddWindowsPrinterConnection printer3
' WSHNetwork.SetDefaultPrinter defprinter
' END IF
'
if department = "ADM" then
printer1 = "\\rgc-1\adm-office"
printer2 = "\\rgc-1\adm-phoenix"
printer3 = "\\rgc-1\adm-cash"
printer4 = "\\rgc-1\adm-dev"
printer5 = "\\rgc-1\smt-head"

Select Case department_location
case "OFF" defprinter=printer1
case "PHO" defprinter=printer2
case "CAS" defprinter=printer3
case "DEV" defprinter=printer4
case "HMS" defprinter=printer5
End Select

' if department_location = "OFF" then
' bind_line = bind_line & " /c " & printer1
' end if


bind_line = bind_line & " /cd " & defprinter

END IF

' if department = "TEC" then
' printer1 = "\\rgc-1\com-t2"
' printer2 = "\\rgc-1\com-t3"
' printer3 = "\\rgc-1\com-t4"
'
' Select Case department_location
' case "t02" defprinter=printer1
' case "t03" defprinter=printer2
' case "t04" defprinter=printer3
' End Select
'
' WSHNetwork.AddWindowsPrinterConnection printer1
' WSHNetwork.AddWindowsPrinterConnection printer2
' WSHNetwork.AddWindowsPrinterConnection printer3
' WSHNetwork.SetDefaultPrinter defprinter
' END IF
'
' if department = "BUS" then
' printer1 = "\\rgc-1\bus-g1"
' printer2 = "\\rgc-1\bus-g2"
'
' Select Case department_location
' case "g01" defprinter=printer1
' case "g02" defprinter=printer2
' End Select
'
' WSHNetwork.AddWindowsPrinterConnection printer1
' WSHNetwork.AddWindowsPrinterConnection printer2
' WSHNetwork.SetDefaultPrinter defprinter
' END IF
'
' if department = "JUN" then
' printer1 = "\\rgc-1\com-t2"
' printer2 = "\\rgc-1\com-t3"
' printer3 = "\\rgc-1\com-t4"
'
' Select Case department_location
' case "t02" defprinter=printer1
' case "t03" defprinter=printer2
' case "t04" defprinter=printer3
' End Select
'
' WSHNetwork.AddWindowsPrinterConnection printer1
' WSHNetwork.AddWindowsPrinterConnection printer2
' WSHNetwork.AddWindowsPrinterConnection printer3
' WSHNetwork.SetDefaultPrinter defprinter
' END IF
'
' if department = "LSP" then
' printer1 = "\\rgc-1\com-t2"
' printer2 = "\\rgc-1\com-t3"
' printer3 = "\\rgc-1\com-t4"
'
' Select Case department_location
' case "t02" defprinter=printer1
' case "t03" defprinter=printer2
' case "t04" defprinter=printer3
' End Select
'
' WSHNetwork.SetDefaultPrinter defprinter
' END IF
'
if department = "SMT" then
printer1 = "\\rgc-1\smt-head"
printer2 = "\\rgc-1\smt-aht2"


Select Case department_location
case "HMO" defprinter=printer1
case "DHM" defprinter=printer1
case "AH2" defprinter=printer2
End Select

bind_line = bind_line & " /cd " & defprinter
END IF


END IF
'WScript.Sleep(1000)
'wscript.echo bind_line
objShell.Exec (bind_line)
 
M

Matjaz Ladava [MVP]

You can try using following sctipt to map network printers at logon time:

On Error Resume Next
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\server\printer"
WshNetwork.SetDefaultPrinter "\\server\printer"

Assign this script as logon script in a GPO of users OU.

--
Regards

Matjaz Ladava, MCSE (NT4 & 2000), Windows MVP
(e-mail address removed)
http://ladava.com
 
J

Jim Florence

Matjaz,

Many thanks for the reply.

In the script I attached you may see we have already tried this. The real
problem seems to be trying to work out what privileges users need to
actually add printers.

As this is a school environment we have tied down the stations pretty tight
but we need to be able to get this running. 5 days and counting. Any
pointers you can give gratefully received

Jim Florence
 
M

Matjaz Ladava [MVP]

You don't need special privileges to run this script. This script should
work as well for normal users as for administrators. I have implemented this
several times, and it works. In your place I would start with a basic script
(just few lines of code) and first check, that the scripts are running well.
Next, I would implement Error Handler in my script, so that you get error
description if the error occurs. Post back your results, as I'm peaty sure,
that the problem lies somewhere else.

--
Regards

Matjaz Ladava, MCSE (NT4 & 2000), Windows MVP
(e-mail address removed)
http://ladava.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top