help with changing preferences and finder properties with applescript?

Hi,

I’m trying to create an applescript app that would change some settings on the computer to my (client’s) desired ones. I’ve figured out how to add apps to login items and turn on password for screen saver and sleep. Now I still need to change the clock to 24h mode and make finder display local hard drives and network mounts on the desktop.
I need to do this either with applescript (this is preferred) or alternatively with bash script if applescript for some reason doesn’t work here.

Can somebody help with this?

Hi,

You can use the following code to set the objects shown on the desktop:


set command to "defaults write com.apple.finder ShowHardDrivesOnDesktop -bool TRUE"
do shell script command

set command to "defaults write com.apple.finder ShowMountedServersOnDesktop -bool TRUE"
do shell script command

set command to "defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool TRUE"
do shell script command

-- now we need to restart the Finder
do shell script "killall Finder"

why not directly ?


tell application "Finder"
	tell Finder preferences
		set desktop shows hard disks to true
		set desktop shows connected servers to true
		set desktop shows external hard disks to true
	end tell
end tell

the MenuBarClock can be set to 24 hour mode with


do shell script "defaults write com.apple.MenuBarClock Use24HourClock -bool true"

Simply because I didn’t know those command existed in Finder’s AppleScript dictionary :smiley: Thanks for pointing this out.

I don’t see this plist on Mac OS X 10.6, so additionally I would suggest the following solution:


set command to "defaults write com.apple.menuextra.clock DateFormat 'E H:mm'"
do shell script command
do shell script "killall SystemUIServer"

Best regards from rainy Berlin…

Martin

Thanks a million! This solved the problem and I now have just one app that changes all my settings to the desired ones.

edit: I spoke a bit too soon, the 24 clock seems to not be working yet.

This gives me an error like this "error “sh: -c: line 0: unexpected EOF while looking for matching `”

Ideas?

edit:
I typoed :slight_smile:

Thanks again. Now everything works!

Did you overlook the single quote before the double quote at the end?