Help with adding bonjour printers using applescript


I have a full lab of iMacs which they need to have 3 network printers. The printers can be seen as bonjour on the IMac. I would love to automate the adding by using an applescript.

Can anyone present an applescript for adding three bonjour printers?

Hello and welcome! :slight_smile:

Have you searched for some bits and pieces?

Or, can you try to describe what you are after in some more detail?

I have very little experience with Bonjour, and therefore it could be fun trying to help you out.


Most of the new printers such as Epsons, and Dell, etc. they all come with a protocol that allows Mac computers to discover them on the network. But, this is not the issue. The issue is to create an applescript that will go to print and fax to mount three specific printers.

For example, when opening the print & fax application, one gets the choice to add printers. After clicking on the “+” symbol a dialogue box opens given the opportunity to choose from the default tab, fax, ip and/or windows.

At this point, by selecting default tab, one can choose the printer or printers to be mounted. The printers that I need to be mounted are shown here, as they were discover by the bonjour protocol. All I need is to automate this process everytime the users logs into twenty-five iMacs.

As you can see, this is a classroom of twenty-five computers. The students should not need to worry about mounting printers, or adding printers, but to be able to click on the print option and go.

Do you have any experiences with applescript? And could you show an example for mounting the three network printers during login process?


During the login process, from a users point of view yes!

I believe there are several ways to achieve to choose a printer, one is to simulate a user, by UI Scripting, the other would be to either edit, or overwrite a printer property list file. (Which will be transparant to the user, I am off and away from my printer until monday, so I can’t test anything, but I’ll try to come up with something for you to test within the same time tomorrow.

Just a thing I wonder about; can’t you, as an adminstrator set up a default printer for all users that log on to the machine? Or is this every user have to do by them self?


Hello, I found this link: PaperCut KB | Copying Printer Config from one Apple Mac To Another.

I might see you walking around with a memory stick, and a administrator password in the near future. :wink:

If I understand it well, you’re doing it wrong.

a bit obsolete, but a start:

I’m sure that is much closer! :slight_smile:


I found a script that seems to be very close to what we need in my location. The script is doing almost everything with the exception of adding the printer. Can anyone look into this code? Perhaps, among all of us can debug the code and get the benefit for using at our respective locations.

tell application “AddPrinter” to activate
tell application “System Events” to tell process “AddPrinter”
set address to “” – printer ip address variable
set printername to “EPSON R3000 #1 @ PRINTSERVER” – Printer name varaible
set printerlocation to “ROOM ABC” – Printer Location

-- Set Protocol:
tell group 1 of window "Add Printer"
	tell group 2
		click pop up button 1
		click menu item "DEFAULT" of menu 1 of pop up button 1
		click combo box 2
	end tell
	keystroke (address) -- sets ip address from address variable
	keystroke tab
	keystroke tab
	delay 5
	keystroke (printername) -- sets printer name
	keystroke tab
	keystroke (printerlocation) -- sets location of printer
	delay 5
end tell

-- Add Printer
tell window "Add Printer"
	click button "add"
end tell
delay 4
tell sheet 1 of window "Add Printer"
	tell group 1 of group 1
		click button "Continue"
	end tell
end tell

end tell

AFAIK. You have to walk around to each and every one of the 25 computers anyway and install the script?

I don’t know how to, and doubt that it is possible to add it via remote desktop, but then, if you have remote desktop, then you should be able to open a terminal window, and set up and execute the shell script, which configures the printer once and for all!

It is your problem, and you who decides upon the solution, I just don’t see the necessity of such a script.

The shell script solution, is a much stabler thing than the gui thing, so please try to look at it.

From what I have read so far, on other forums, some technicians are using lpadmin to add the printers to the local computer. If am not mistaking, lpadmin add the printers to the local CUPS.
Can you please provide an example for using a shell script?

Please see the link in post #5

Have a look at both that and the article encompassing the script! I think that is a very sound aproach. It works by copying a premade config file into an etc directory, for cups to pick up and use.

I might even be able to write a little applescript to make the running of the script easier for you!

Super! Let me know when is available.

You have a little bit of work to do, how do you plan on using the script in post #5 for instance. Have you actually read the link? :expressionless: