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.
What does that script look like? @geoffrey-obrien
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
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)
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"
@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.
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
@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.
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
@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.
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.
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...
@fdeltesta Sorry - what's here is the best I found.