I have a need to temporarily quit the process “SyncServer” while I update Address Book Records. Is there a way to do this using applescript. You can manually quit the process by launching iSync and unchecking the checkbox “Enable syncing…” in Preferences>General but I would like for this to happen transparently for the user. At the end of the I would also like to be able to restart the “SyncServer” Process using AppleScript.
The process shows up in Activity Monitor but is not visible to “System Events” in AppleScript. Any ideas or help would be appreciated.
If you have a .Mac account, this script will reveal the Sync pane. I don’t have an account so you’ll have to find the button yourself.
tell application "System Preferences"
set current pane to pane id "com.apple.preference.internet"
reveal (first anchor of current pane whose name is "sync")
end tell
set sync_id to first word of (do shell script "ps -ax | grep SyncServe | grep -v grep")
do shell script "KILL -STOP " & sync_id -- this pauses the process.
do shell script "KILL -CONT " & sync_id -- this brings it bac
You can also kill the process by using
do shell script "KILL " & sync_id -- this KILLS the process
If you KILL the process, you would have to find aw way to relaunch it.
activate application "iSync"
tell application "System Events"
tell process "iSync"
keystroke "," using {command down}
tell window "iSync Preferences" to click checkbox "Enable syncing on this computer"
end tell
end tell
When “Enable syncing” is unchecked in iSync’s preferences, a .plist file named com.apple.syncservices.[yourMACaddress].plist
appears in ~/Library/Preferences/ByHost/ with one entry SyncingDisabled YES in it.
But I don’t know either how to set this. When the box will be checked, the file disappears
StefanK, Good spot. I did look in my byhost folder as I saw the date modified had change, But of course evey time I looked in there I could not see what changed. which puzzled the hell out of me.
So Here is the answer, You’re right when the file is there the Syncing is disabled, when its not there syncing is enabled.
So the simple thing would to either move the file with the script or rename it.
I chose to rename it.
set the_get_mc to do shell script "ifconfig en0 ether | grep -i ether" as string
set the_code to words 2 thru 7 of the_get_mc as string
set plistPath to "~/Library/Preferences/ByHost/com.apple."
set plistName to "syncservices." & the_code & ".plist"
try
do shell script "MV " & plistPath & "¢" & plistName & " " & plistPath & plistName -- disable
end try
set the_get_mc to do shell script "ifconfig en0 ether | grep -i ether" as string
set the_code to words 2 thru 7 of the_get_mc as string
set plistPath to "~/Library/Preferences/ByHost/com.apple."
set plistName to "syncservices." & the_code & ".plist"
try
do shell script "MV " & plistPath & plistName & " " & plistPath & "¢" & plistName --enable
end try