Search code examples
macosapplescript

Find Mac OSX version installed using AppleScript


How can I find which version of OSX is installed on my Mac by using AppleScript? I want to install an app programatically and run different pkg files based on the version.

Thanks


Solution

  • I'm not on a Mac, so there may be a better way to do this, but the first approach that comes to mind is just executing a shell command to query the OS version.

    http://developer.apple.com/technotes/tn2002/tn2065.html#TNTAG2

    http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/sw_vers.1.html

    Based on these references, you probably want to do something like:

    set os_version to do shell script "sw_vers -productVersion"