Skip to main content
Question

Disable Printer Sharing

  • June 30, 2014
  • 14 replies
  • 68 views

Forum|alt.badge.img+16

There was a post i saw from 2012 that mentioned you could disable Printer Sharing with "cupsctl --no-share-printers"

That doesn't really uncheck and grey out the "Printer Sharing" service though. Is there a way to lock it down? Internet Sharing was easy enough with com.apple.nat

14 replies

Forum|alt.badge.img+3

I use the cupsctl method, but I also install all our printers via a script and set the sharing option to off during that process as well.


Forum|alt.badge.img+5
  • Contributor
  • January 20, 2015

What does that script look like? @geoffrey-obrien


bentoms
Forum|alt.badge.img+35
  • Hall of Fame
  • January 22, 2015

Forum|alt.badge.img+33
  • Hall of Fame
  • January 22, 2015

I've got a script that I use to disable printer sharing for individual printers after they've been set up. It's available from here on my Github repo:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Casper_Scripts/disable_printer_sharing


Forum|alt.badge.img+12
  • Contributor
  • January 22, 2015

This will disable sharing on all currently installed printers. Not just known/named ones.

https://gist.github.com/rmanly/bf28847ddec8e3f0bd03

#!/bin/bash

while read -r _ _ printer _; do
    /usr/sbin/lpadmin -p "${printer/:}" -o printer-is-shared=false
done < <(/usr/bin/lpstat -v)

Forum|alt.badge.img+20
  • Contributor
  • February 19, 2015

To implement this in Casper it says to use the Files and Processes option when making a policy

The last option within Files and Processes is Execute command, so you would paste the command into the field and once your printer is installed, the command will execute and remove the sharing on that printer only.

lpadmin -p <printer_name> -o printer-is-shared=false

would I need to put the <printer_name> in quotes "MY Printer is"


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • February 19, 2015

@tcandela - generally speaking when talking about unix commands, its a good idea to quote strings, especially if there are spaces in them. If your printer name has spaces in it then definitely enclose it in quote marks.


Forum|alt.badge.img+20
  • Contributor
  • February 19, 2015

I am going to stick the command in the Files and Processes Execute section, here is the command my printer name has spaces
lpadmin -p "My Printer name" -o printer-is-shared=false

If i wanted to use this in a script instead, what priority would i use ?
In Casper Admin I have a 'Script' category set at 15, priority 'After'

#!/bin/bash
# A HARDCODED VALUE FOR "Printer_Name" CAN BE SET BELOW.
#
# Delete the double quotes and replace with the desired printer_name,
# This script disables printer sharing on a designated printer.
# If this script is to be deployed via policy using the JSS leave the next line as is.

printer_name="$4"
lpadmin -p "$printer_name" -o printer-is-shared=false
echo "Print Sharing for $printer_name has been disabled."
exit 0


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • February 19, 2015

@tcandela - A Category's priority has no bearing on how the script or package will run when its in that category. It only affects where the Category label shows up within Self Service.


Forum|alt.badge.img+20
  • Contributor
  • February 20, 2015

when the script runs via Casper, were does the echo "message" get displayed? or is it just ignored?

when i run the script from the command line, i see the echo 'message' in the terminal


Forum|alt.badge.img+3
  • New Contributor
  • March 2, 2015

@tcandela

when the script runs via Casper, were does the echo "message" get displayed? or is it just ignored?

You'll see it in the logs on the JSS.


Forum|alt.badge.img+8
  • Contributor
  • February 13, 2019

These solutions all disable sharing, at the printer level. I believe the OP wanted to know how to Disable (and gray out) the Printer Sharing checkbox in the Sharing Preference Pane.


Forum|alt.badge.img+7
  • Contributor
  • April 2, 2019

Hello, @JayDuff Your suggestion is indeed something I am actually trying to find. Do you or anybody have a clue ? I have though about disabling the general printer sharing options and then hiding the "sharing" section from the preference panel but not so happy with that solution...


Forum|alt.badge.img+8
  • Contributor
  • April 2, 2019

@fdeltesta Sorry - what's here is the best I found.