Recently Dave C asked: "Simple script used to work, not now", which prompted me to carry out some tests in Mt. Lion which I finished yesterday.
Using do shell script "defaults write com.apple.Finder AppleShowAllFiles 0" in Mt. Lion works, but the purpose of my tests was to determine why writing Finder's pref file with System Events does not work and how it can be fixed.
In Lion and previous OS's my script: 1. Quits the Finder; 2. Writes the file "com.apple.finder.plist" via System Events; 3. Reads the changed value to verify the write (testing only); 4. Launches and activates the Finder. and it works perfectly.
When this script is run in Mt. Lion, it seems to work the first time, then refuses to work at all on repeated runs. (No errors, it just has no effect.) I finally pause for a minute or so due to frustration and to check my code. Then I try one more time … and it works! (There seems to be a timing problem.)
I have also tried changing the value of AppleShowAllFiles manually via Xcode and that does not always work.
Something strange seems to be happening with the Finder's prefs file in Mt. Lion. I have come to the conclusion that using System Events to modify the Finder's prefs file no longer works due to unknown changes introduced in Mt. Lion. Using System Events to modify the prefs file for other applications may also be a problem also. (Using System Events to modify the prefs file for an application you have written seems to be OK.)
Conclusion … System Events does not work with Finder's prefs file and it can not be fixed.
|