Change password for local account - AppleScript

jonros
Contributor II

Hello,
We have a compiled AppleScript that users can click to access their account and bring up the password change window locally on their computer. It has worked great up to Monterey. But since Ventura it doesn't work at all! It opens System Preferences and Users and Groups but then it stops.

Anyone who is sharp on AppleScript and has a solution or some good advice?

6 REPLIES 6

Raffael
New Contributor II

Can you provide the script so it can be checked for errors ? When you test the script in the editor, does it work ? 

 

Have a good one,

Raffael

a_hebert
Contributor

Might want to post the script so it can be looked at.

jonros
Contributor II

Problem is, I can't find the source-file 🙈

AJPinto
Honored Contributor II

We would need the script to look at it. It should be in {jamfserverurl}/view/settings/computer-management/scripts, the script's name should be in the policy you are using. 

 

With Ventura Apple rebuilt System Preferences and rebranded it to System Settings. Many of the Preference Pane paths changed. Derflounder has a good blogpost written up about it.

 

 

jonros
Contributor II

Found it!

set userName to short user name of (system info)

do shell script "system_profiler SPHardwareDataType | grep Serial"

set serial to result

set ipadress to IPv4 address of (get system info)

 

-- Create a dialog with 3 buttons

display dialog "Verktygsprogram Mac - användare: " & userName buttons {"Byt lösenord", "Reparera Wi-Fi", "Reparera inloggning"} default button 1 with title "Båstads kommun - Verktygsprogram Mac v.1.0" with icon caution

 

--Change password

if result = {button returned:"Byt lösenord"} then

tell application "Finder" to open file "Accounts.prefpane" of (path to system preferences)

 

tell application "System Events"

tell application process "System Preferences"

delay 1

click button -1 of tab group 1 of window 1

end tell

end tell

 

--Repair Wi-Fi

else if result = {button returned:"Reparera Wi-Fi"} then

 

do shell script "networksetup -setairportpower en0 off"

do shell script "sudo networksetup -removepreferredwirelessnetwork en0 BastadsKommun" with administrator privileges

do shell script "networksetup -setairportpower en0 on"

display dialog "Anslut nu till Wi-Fi: BastadsKommun med ditt användarkonto" buttons {"OK"} default button 1 with icon stop

 

--Reparera inloggning

else if result = {button returned:"Reparera inloggning"} then

 

display dialog "Reparerar inloggning... OBS! Din dator kommer att startas om." buttons {"OK"} default button 1 with icon stop

delay 3

do shell script "rm -R /Users/$3/Library/Keychains" with administrator privileges

tell application "System Events"

restart

end tell

 

else

display dialog "Båstads kommun" buttons {"OK"} default button 1 with icon note

end if

Where it says tell application process "System Preferences" would need to be changed for one to tell application process "System Settings"