applescript determines which OS, then launch file off cd?

ok first off, I cant use toast, I am developing on a PC (sad). I have installers for 3 different OSes, windows, os x and os 9. I was wondering if its possible to write an applescript that will check which version of the os is running (9 or X) then launch the corresponding installer of a cd when the cd gets inserted.

Thanks in advance for the help.

This might help to determine the version.

thanks for the reply. there was a little bit there about checking the system version. Now I need to get iit to start a partfular file depending on the os…and i dont know anything about applescript.

This might be close. You’ll need to supply the paths to the files you want to open (in the lines marked with – ***). That should be about all you need to change.

copy my gestaltVersion_info("sysv", 4) to {system_version, system_string}

if the system_version is less than "1000" then -- this checks for OS X 10.0.0
	tell application "Finder" to open file "path:to:OS9:file" -- ***
	tell application "Finder" to open file "path:to:OSX:file" -- ***
end if

-- Don't mess with the stuff below --

on gestaltVersion_info(gestalt_code, string_length)
		tell application "Finder" to ¬
			copy my NumToHex((system attribute gestalt_code), ¬
				string_length) to {a, b, c, d}
		set the numeric_version to {a, b, c, d} as string
		if a is "0" then set a to ""
		set the version_string to (a & b & "." & c & "." & d) as string
		return {numeric_version, version_string}
	on error
		return {"", "unknown"}
	end try
end gestaltVersion_info

on NumToHex(hexData, stringLength)
	set hexString to {}
	repeat with i from stringLength to 1 by -1
		set hexString to ((hexData mod 16) as string) & hexString
		set hexData to hexData div 16
	end repeat
	return (hexString as string)
end NumToHex

ok it turns out i can use toast…so how can i get this applescript to autostart off the cd? i know there is an autostart checkbox in toast, but i think that just starts the cd itself, i need to actually start the script.

one more question…is the path to the file relative to where the applescript is located? or do I have to use an absolute path from the cd?

If you click that checkbox, you’ll be prompted to choose a file to launch.
Toast Help
Note: This feature is available only on Mac OS 9.1 or later.
1 To select an application that opens automatically when you insert the CD into a CD-ROM player, click the AutoStart check box.
2 In the Open dialog box, select the file you want and click Open.
If you decide not to select an AutoStart file, click the AutoStart check box to deselect it.
If you need to change the selected file, click its name. The selection dialog box appears again.
If you select a file (rather than an application) to AutoStart, make sure that the application needed to open that file is available on the target system or the CD.

Problems with AutoStart?
If a program recorded with AutoStart on your CD fails to start, you may not have the correct QuickTime extensions installed or enabled.
1 Open the QuickTime Settings control panel.
2 In the dialog box that appears, choose AutoPlay from the pop-up menu.
3 Activate Enable CD-ROM AutoPlay.
4 Close the dialog box.
When you restart your computer, this setting takes effect. (With newer systems, you don’t need to restart.)
If Enable CD-ROM AutoPlay is not listed, download and install QuickTime version 4.1.2 or later.

thanks jj…i havent getten a chance ot play wiht toast enough to cehck out the help files yet.

anyone know about the path question?

I allways like relative paths… Are more safe! Or better, create your own full qualified path on the fly every time the script run.
Eg, look at this hierarchy:

  • CD:
    Script Autorun
    -MacOS stuff Foldermacos installer script-MacOSX stuff FoldermacosX installer script
    To launch “macosX installer script” from “Script Autorun”:
set AppleScript's text item delimiters to ":"
set | folder which contains me | to text items 1 thru -2 of (path to me as text) & "" as text
--> to go 1 level up, choose "text items 1 thru -3"; to go 2 levels up, "1 thru -4"; and so on...
set AppleScript's text item delimiters to {""}

set macosX_installer to | folder which contains me | & "MacOSX stuff Folder:macosX installer script" as alias

tell app "Finder" to open macosX_installer

If you mantain the hierarchy, this should work everywhere…

Good luck! :wink:

ok i am tyring that script, and when i run it in os X (10.2) it is trying to launch classic. any ideas?

It might depend on which OS it was compiled with. I don’t have classic installed, so I can’t test the theory, but it seems that a lot of people have problems where the wrong version of an application is launched and I don’t recall anything suggestions that overcome the issue 100% of the time.

ok, it seems to be working fine…in OS 9. I mad ethe script an applications, which then autostarts when the cd is inserted. The problem is, cd’s dont want to seem to autostart in OS X, as far as I can tell. I know it was a quick time setting in 9, but I cannot find any options for it in X, and no documentation on it anywhere on the web. Can anyone help me out?

Thanks in advance…

In Jaguar, there’s a preference pane named “CDs and DVDs”. I don’t know how it’s handled in OS X versions prior to Jaguar.

yeah, the cd&dvd pane lets you set actions to take for blank, music and picture cd’s and dvd’s.

I dont see how to set that to autorun a cd that has an applescript and installers on it.

Ok, I wasn’t sure. In Jaguar, it also has the option to run a script but I don’t see any options for data CDs/DVDs. I wonder if there’s a way you could trick it by placing a movie or music file on the CD. I don’t do any burning so I’m ignorant of the differences in the various formats.

tricking it wouldnt work, i dotn think…if we made a music cd it would open itunes, pics it would open IPhoto, etc…

Here (and other places) say that it is absolutely impossible ‘autostart’ under OS X:

Perhaps you can drop a note at apple discussion groups and see if anybody knows about this (since this is an apple-OS-specific question, and there are lots of cool guys at their forums)…

Good luck! :wink:

Is it possible to check for Quicktime?

i would imagine so, but the option to autostart cd’s isnt a quick time option anymore…you may want to start a new thread if all you want to do is figure out how to check for quick time.

Definitively, this thopic is closed until a new release of MacOSX allows autostart features.
And, also:

     tell application "Finder" to application file id "TVOD"
on error
     -- No QuickTime, absolutely strange stuff, since it's a basic OS component
end try