Why does this script not work?

I’m trying to write a script which will access system preferences and change to OS 9.2.

tell application “System Preferences”
set startup disk of alias “Macintosh HD:” to “Mac OS 9.2.2”
end tell

But this does not work. I get an “access denied” error. I am very frustrated with the verbage in Applescript. there does not seem to be documentation on this and the application’s dictionary does not help either. does anybody have any suggestions. I have 2 books on applescript and they both suck.

I don’t see anything in the AppleScript dictionary of System Preferences that indicates that your script would work. As far as I know, the only way to do this in OS X is by using GUI Scripting. If this is the way you decide to go, I have a script that you might be interested in. It isn’t complete (it needs error checking and final tweaking) but it might serve as a starting point for you. FYI, it also requires Extra Suites.

Hey, that sounds cool! I’d like to take a look at that script! :slight_smile:

/arvid

Okey dokey. On my machine, this script will select the second disk from the left in the Startup Disk pane. It may need to be localized for non-English systems.

-- Open startup disk pane
tell application "System Preferences"
	activate
	set bounds of window 1 to {278, 32, 873, 600} -- for consistent location
	repeat with thisPane in panes
		if localized name of thisPane is "Startup Disk" then
			set current pane to thisPane
			exit repeat
		end if
	end repeat
end tell

delay 2 -- might not be needed

-- Select new disk as startup disk
tell application "Extra Suites"
	move mouse {500, 190}
	click mouse
end tell

-- Restart computer
tell application "System Events" to tell application process "System Preferences"
	tell button "Restart?" of window "Startup Disk" to click
	tell button "Save and Restart" of sheet 1 of window "Startup Disk" to click
end tell -->

The coordinates will likely need to be modified to reflect your setup. I wrote this for myself and it isn’t complete so there is no error checking or optimization. It is offered only as a crude working example. :slight_smile:

[Tested successfully on a OS X 10.2.5 US English setup.]

What is the application “Extra Suites”.

Visit Kanzu to find Extra Suites.

Cool script! :slight_smile:

/arvid

You may be able to switch your boot volume/folder using the command-line utility ‘bless’

Type man bless in the Terminal to read more about it. Be careful, you could render your computer unbootable if you do it wrong.

Hmm, it looks like someone has already done all the hard work over at MacOSXHints.com - http://www.macosxhints.com/article.php?story=20020302215826526&query=bless

They’ve got the command-line stuff; but even better, they wrote an AppelScript that does the whole thing. :slight_smile: Enjoy!