I’m trying to make a starup app that goes into System Preferences and checks to see if FTP Access, Remote Login and Apple Remote Desktop are enabled, and checks the boxes if they are not already checked.
This script checkes the boxes, but checks the boxes every time, no matter the state.
tell application "System Preferences"
activate
delay 1
end tell
tell application "System Events"
tell process "System Preferences"
set frontmost to true
click menu item "Sharing" of menu "View" of menu bar 1
delay 2
tell window "Sharing"
set theRow to item 1 of (rows of table 1 of scroll area 1 of tab group 1 whose value of static text 1 is "FTP Access")
click checkbox 1 of theRow
end tell
tell window "Sharing"
set theRow to item 1 of (rows of table 1 of scroll area 1 of tab group 1 whose value of static text 1 contains "Desktop")
-- For some strange reason "Apple Remote Desktop" cannot be found
click checkbox 1 of theRow
end tell
tell window "Sharing"
set theRow to item 1 of (rows of table 1 of scroll area 1 of tab group 1 whose value of static text 1 is "Remote Login")
click checkbox 1 of theRow
end tell
end tell
This script returns an error of the following:
System Events got an error:
NSReceiverEvaluationScriptError: 4
tell application "System Preferences"
activate
delay 1
end tell
tell application "System Events"
tell process "System Preferences"
set frontmost to true
click menu item "Sharing" of menu "View" of menu bar 1
delay 1
tell window "Sharing"
if value of checkbox "FTP Access" of (rows of table 1 of scroll area 1 of tab group 1 whose value of static text 1 is "FTP Access") is false then
click checkbox 1 of theRow
end if
end tell
tell window "Sharing"
if value of checkbox "Desktop" of (rows of table 1 of scroll area 1 of tab group 1 whose value of static text 1 contains "Desktop") is false then
click checkbox 1 of theRow
end if
end tell
tell window "Sharing"
if value of checkbox "Remote Login" of (rows of table 1 of scroll area 1 of tab group 1 whose value of static text 1 contains "Remote Login") is false then
click checkbox 1 of theRow
end if
end tell
end tell
end tell
Any help would be appreciated.
Thanks!