Deleting Printers from Printer Setup Utility

I am trying to write a script to delete all “Generic PostScript Printers” from the printer list. I’m using a script because I need to ARD it to 1000 computers.

Here it is:


tell application "Printer Setup Utility"
	activate
	set i to 1
	set thecount to the count of printers
	repeat until i = thecount
		if the kind of printer i = "Generic PostScript Printer" then
			delete printer i
		end if
		set i to i + 1
	end repeat
end tell

If I read the event log, it loops by all the printers and it says it deleted the GPSP, but they are still on the list! Any ideas?

Using Panther.

Model: iMac/eMac/Towers
Browser: Safari 312
Operating System: Mac OS X (10.4)

Wow… 1,000 macs. Better you than me.

Not too familiar with this, but maybe better to go low-level and do it in cups instead of printer setup?

For example, this would delete the printer called “AdobePDF”…

http://localhost:631/admin/?op=delete-printer&printer_name=AdobePDF

You could call that url with curl, either from apple script with a do shell script, or you could just write a shell script.

CUPS admin base is http://localhost:631/. You can get to the docs from there.

There is more to it then that.

That would simply remove it from the CUPS file, and then it would be instantly updated again because of all the computers with printer sharing. We just need to remove it with the files from the Printer list, which is per-user…

I’ve got the same problem and apple script dies when I try to delete the printer on 10.4.3. I can get the error when I’m back at my other office.

Model: PowerMac G5 2x1.8Ghz
Operating System: Mac OS X (10.4)

Ok finally got to a Mac, the error is “Printer Setup Utility got an error: NSInternalScriptError” and I’m not really sure what is wrong

Thanks for any help

I realize I’m posting this in a 7+ year old thread, but.

This old Mac OS X Hints article seems to point to a shell script command you could use. lpadmin:

http://hints.macworld.com/article.php?story=20061203221317612

the bash line is

lpadmin -x Printer_Name

where Printer_Name is the printer name :smiley:

Maybe if the kind of printer is generic post script, then get the name of the printer and “do shell script” using the lpadmin command.