Change startup disk and restart by a script?

A colleague asked whether there was a way for his students to restart in OS 9 (a separate volume) without him having to log them out, log in as admin in X, and manually change the startup disk. I’ve checked the Finder, System Events, and other dictionaries and I don’t see a way to do it. Is there a do shell script that might work? It would have to have admin privileges and that’s a problem I think because the admin password would have to be hard coded into the script in order to access the “Startup Disk” prefs Pane.

Basically he wants this meta-code:


tell app "System Events" to set startup disk to "OS 9" using password "password"
tell app "Finder" to restart ignoring system responses

Any ideas would be appreciated.

Hi,

You can do something like this to enter the password on the first run only:

property first_run : true
property the_password : “”

if not first_run then
beep 3
– your stuff here
else
display dialog “Enter the password:” default answer “”
set the_result to result
set the_password to text returned of the_result
set first_run to false
end if

There are still ways to get the password but the students would need to look in the resource fork. To go further you could make it run only.

gl,

Thanks. We determined that a “do shell script” of “sudo bless…” will set the startup disk, so we could use your code to provide the password to the sudo command (I think you can configure sudo to read the pw from a file which could be write only). But themain question is, is there a way to set the startup disk from pure Applescript? I sure can’t find it.

I don’t think there is. The “startup” property of a disk is read only so unless there’s another method of dealing with startup disks in AS, it’s probably not possible. You could do it with GUI Scripting but why worry about that when the do shell script would be so much quicker, cleaner, and easier.