Need help to create a script for adding printers....

Hello,

I currently have 7 MAC that has OS X. I’ve been trying to write a script so that everytime a user logs in to that computer, the script will automically add the printers that they need for the users so they don’t have to manually add the printers themselves everytime. I would appreciate any help on this since I’ve been met with many dead-ends and frustrations.

Many thanks,

Bryson

Hi Bryson

Not sure what you mean here.
I thought that once you’ve added a printer its always there until you delete it.
unless your creating a new user everytime!!
More info if you can with this one please!

Okay,

Basically, I have a lab setting where we have three printers. I’m trying to set it up like I did with the PC by using VBS but MAC doesn’t accept VBS. Here is the code that I used for PC:

’ **************************************************************************
’ * Program: printer_setup.vbs
’ * Purpose: Everything to do with printers
’ * add and remove printers
’ * Set default printer if needed
’ *
’ * Date: 9/12/2006
’ **************************************************************************
On Error Resume Next

Dim printer_color, printer_remove_color

printer_color = “\nissrv7\NLCprsclbjcolor01”
printer_remove_color = “\nissrv7\can1120”

Set wshNetwork = CreateObject(“Wscript.network”)
'remove old color queue
wshNetwork.RemovePrinterConnection printer_remove_color, true, false
'set new color queue
wshNetwork.AddWindowsPrinterConnection printer_color

'-----------------------------------------------------
'Set default printer depending on computer location
'-----------------------------------------------------
'Classroom 1 - NLCCR01
'Smart Classroom - NLCSC01
'Classroom 2 & 3 - NLCT01
'General Lab - NLC01

Dim computer, length, nlc, area, num

'Set printer path
Dim printer_1, printer_2, printer_special, printer_smart

printer_1 = “NLCPrint01”
printer_2 = “NLCPrint02”
printer_special = “NLCSpecial”
printer_smart = “NLCSmart”

computer = Trim(wshNetwork.ComputerName)
length = Len(computer)
nlc = Left(computer, 3)
area = Mid(computer, 4, 2)
num = CInt(Right(computer, 2))

'--------------------------
'Smart Classroom or Classroom #1
If(length = 7) Then

'Classroom #1
If (area = "CR") Then
	wshNetwork.SetDefaultPrinter printer_special

'Smart Classroom
ElseIf (area = "SC") Then
	wshNetwork.SetDefaultPrinter printer_smart

'Everything else
Else
	wshNetwork.SetDefaultPrinter printer_special
End If

'--------------------------
'Classroom #2 #3
ElseIf (length = 6) Then
wshNetwork.SetDefaultPrinter printer_1

'--------------------------
'General Lab
ElseIf (length = 5) Then
'Between PC-1 and PC-7 - Carrels
If (num <= 7) Then
wshNetwork.SetDefaultPrinter printer_1

'Between PC-8 and PC-13 - Carrels
ElseIf (num >= 8 And num <= 13) Then
	wshNetwork.SetDefaultPrinter printer_2

'Between PC-14 and PC-24 - Right side of NLC facing entrance door
ElseIf (num >= 14 And num <= 24) Then
	wshNetwork.SetDefaultPrinter printer_1

'Between PC-25 and PC-32
ElseIf (num >= 25 And num <=32) Then
	wshNetwork.SetDefaultPrinter printer_2

'Above PC-33 - NCE Area
ElseIf (num >= 33) Then
	wshNetwork.SetDefaultPrinter printer_special

'All other computers default to special printer
Else
	wshNetwork.SetDefaultPrinter printer_special
End If

'--------------------------
'Everything else
Else
wshNetwork.SetDefaultPrinter printer_special
End If

Now, I need to convert this to AppleScript which I’m not even familiar with but been trying to learn it. :slight_smile: Anyhow, the purpose of this script is to locate the nearest printer and set it as default to make it easier for the peers in the lab. Thanks agian for your help.

Regards,

Bryson

Hi Bryson

Not sure how you would find the nearest printer in the room using applescript!
Maybe someone else on the forum can help you with that.

What i know you can do is set up a pool so your lab guys can send a job to print and the first available printer out of the three
thats not busy will print the job, but you do that with out applescript.

Here are a couple of ways of making a chosen printer the default though:

tell application "Printer Setup Utility"
	set mylaserprinter to "Cyclone_CLC" -- Printer name
	set current printer to first printer whose name is mylaserprinter
end tell

and with a shell script

set the_printer to "Cyclone_CLC"
do shell script "lpoptions -d" & the_printer

Hope this helps a bit (sorry if it doesn’t )