Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
It is an admirable work, with ingenious solutions. But because it uses clicks in System Preferences, it might only work properly on macOS 10.13.6.
On Monterey for example, it randomly returns “System Preferences got an error: Can’t get current pane.” and other errors.
More, on laptops without an Ethernet port, Wi-Fi is en0, not en1.
Fortunately, networksetup gets past that and returns: "en1 is not a Wi-Fi interface. Turning off the only airport interface found: en0"
In the end, it works as you want it and it provides a good template for anybody with a similar problem. 👍
Thanks, I appreciate that :)
In this (and similar ones I've done) I consider myself more as an "information collector/administrator" as I only understand partly what's going on with the coding and don't have the abilities to do it from scratch. But patience, testing and having a clear idea of what I want done helps ;)
And in the end I learn a lot from your and others' help in this thread, which is info I can use in the next project.
I didn't know about that ethernet port thing. Fortunately I have the script working fine on both a Macbook Pro and a Mac Pro. And like you say it could provide as a template for a similar issue (or hopefully to get my next project going).
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
It is an admirable work, with ingenious solutions. But because it uses clicks in System Preferences, it might only work properly on macOS 10.13.6.

Unfortunately, you seem to be right about this.
I just upgraded my mid-2010 Mac Pro from 10.13.6 (which the script worked fine on) to 10.14.6 Mojave today, and it broke.
I tried to troubleshoot with the script editor and for some reason, reintroducing "activate" (which opens up and shows the Sharing system preference with the button presses etc. as the script goes along) makes it work again). Go figure!
So the script is the same as in post #47, except I've now uncommented -- activate.

In other words the start of the script looked like this before:
tell application "Finder" to activate

display notification with title "AppleScript running" subtitle "PLEASE WAIT...."

tell application "System Preferences"
-- activate
reveal (pane id "com.apple.preferences.sharing")
set localized_window to the localized name of the current pane
end tell

but has now been changed to this (changes in red):

tell application "Finder" to activate

display notification with title "AppleScript running" subtitle "PLEASE WAIT...."

tell application "System Preferences"
activate
reveal (pane id "com.apple.preferences.sharing")
set localized_window to the localized name of the current pane
end tell

Apart from that change the script is the same as before.

Does anyone know why this makes a difference? And is there a way that I can keep hiding the Sharing system preference window like before, but have the script still work in MacOS 10.14?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.