How to detect OS running in 64-bit mode?

I thought I could find the answer easily through a search, but I haven’t been able to find it, and will be grateful for any help.

Is there a way for AppleScript (or a shell script) to test whether the OS is running in 32-bit or 64-bit mode? I want my script to launch a different application depending on which mode is being used.

Thanks in advance.

More verbose than it has to be, but it covers the bases:

set M to (do shell script "uname -a")
if last word of M is "i386" then
	display dialog "32 Bit Mode is running"
else if last word of M is "X86_64" then
	display dialog "64 Bit Mode is running"
else if last word of M is "Macintosh" then
	display dialog "This is a Power Macintosh"
end if

This doesn’t work Adam. Because most EFI runs in 32 bit mode on Snow Leopard machines the uname will return i386 mode while cocoa and applications can run in 64 bits mode without any problem. Uname will only tell you in which architecture the kernel is loaded. On my MBP i7 the kernel also loads in 32-bit mode by default and need to hold the “6” and '“4” while booting my mac to force the system to use the 64-bit kernel. While the appkit framework is loaded in 64-bit mode.

I think the best way to determine if snow leopard is running in 64 bit mode or not is by looking how the appkit framework is loaded. In system_profiler command line utility it returns that my system is 64 bit while the kernel is loaded in 32 bit mode.

Excellent DJBW; It didn’t occur to me that there could be mixing like that.

My system_profiler (on my MBP) says:

Where did you find the appkit? Is that “and Extensions”?

About the AppKit when I use the following code in the terminal

system_profiler SPFrameworksDataType

You can see the frameworks that are loaded by the system and if they support 64 bit (appkit shows 64 bit). But after some thinking I thought this is maybe not the correct way to determine of Snow Leopard is running 64-bit mode. It could be possible that in an 32-bit environment system_profiler also will say that it is 64-bit.

Well you can say that if the processor is 64-bit snow leopard will run in 64-bit mode too. A 64-bits processor is able to load the kernel in 64-bit in Snow Leopard. To determine if it’s possible to load the 64-bit kernel you can use the following code.

on kernelCanRunIn64BitMode()
return ((do shell script “sysctl -n hw.optional.x86_64”) as integer) as boolean
on error
return false
end try
end kernelCanRunIn64BitMode

My conclusion was if there is no 64-bit kernel available there is no 64-bit processor and when there is no 64-bit processor there is no 64-bit snow leopard running. Correct me if I’m wrong and i’m also curios if this works in 10.5

Unfortunately, that doesn’t work. My MacBook (MacBook4,1 Intel Core 2 Duo) reports “true” when I run the code you posted, but it can only boot into 32-bit mode. The chip can theoretically boot into 64-bit mode, but Apple doesn’t support that mode with this chip, so there is no way to make OS X boot into 64-bit mode with this machine.

Turns out to be a difficult question; machine species dependent it appears. In the meantime, however, the original poster hasn’t responded, so we really need to know what, specifically, he needs to know. I have a MacBook Pro (early 2008, i.e., 4,1 model) that I’ve always run in 32-bit mode. Tomorrow morning, I’ll test to see if it will run 64-bit.

Hello - I’m the original poster. Here’s what I want to do (which is now slightly different from what I described in my original post - I’ve thought the problem through more clearly since I posted):

The most recent build of the SheepShaver emulator program runs by default in 64-bit mode on 64-bit systems. (It’s available here: I’ve developed an AppleScript bundle that runs SheepShaver and performs various other functions (for example, it installs a folder action script in OS X which makes it easy to print from SheepShaver to the default OS X printer). I want to revise the script so that it will test whether it’s running under a system that will run SheepShaver in 64-bit mode, and, if so, the script will prompt the user to decide whether to run the program in 64-bit mode or 32-bit mode (with an option to decide whether to use 32- or 64-bit mode in the future without being asked.) There are different advantages to 32-bit and 64-bit SheepShaver.

What I’m looking for is a reliable way to test whether the system is one in which the program can run in 64-bit mode.

Thanks for all your suggestions so far. I didn’t realize this problem would be so difficult to solve!


I think you’re talking about the kernel again. When the kernel is 32 bit it doesn’t mean Snow Leopard is 32 bit too. That’s the whole point we’re discussing. Your macbook is also 64 bit because snow leopard on a Intel core 2 duo always try to run in 64 bit. So that’s why we concluded that uname isn’t the way of checking in which mode snow leopard is running, it tells you only how the kernel is loaded. My handler has to be checked on the first Intel core duo processors of the first macbook/pro or iMac using Intel processor, here it should return false and on ppc machines it should return false. On all newer machines it should return true. Because I don’t have all the machines at home I couldn’t test if my conclusion is correct.

Also another question: Are we talking about sheepshaver or it’s emulation running in 32 or 64 mode? It’s an virtual ppc machine so it has nothing to do with the real processor is it maybe possible that you mix these two things?

p.s. never knew that sheepshaver was made by the Dutch

You are right: I had not done all the testing I should have done. My question should have been phrased:

In some systems, when you Get Info, the latest version of SheepShaver has an option “Open in 32-bit mode”. What I am looking for is a test for whether or not that option is available in Get Info, and, if it is, offer that option to the user (with an option to change it permanently). Your test seems to provide the answer I need. Thank you!

SheepShaver, as you say, is a PPC emulator. Internally it runs old Mac OS applications as if in an old PPC machine. The 64-bit option seems to make the emulator slightly faster, but it lacks one or two features that are available with the 32-bit option.

SheepShaver was written originally written by Gwenolé Beauchesne, but the latest builds have been tweaked by Ronald Regensburg and others.

Well reading your first post and last post you can use command line utility arch. Arch can startup unversal applications in a given architecture. I’ve tested the following script with preview but also gave me a flaw. The script can run preview as many times as you want, this is not what we want. The script should check if the process is already running before starting a new process.

Floowing code tested with preview

property lastUsedMode : missing value
if kernelCanRunIn64BitMode() then
	if lastUsedMode is missing value then
		set x to display dialog "In which mode do you want to start the application" buttons {"32-bit mode", "64-bit mode"} default button "64-bit mode"
		set lastUsedMode to button returned of x --set our property permanent so user will not be asked again the next runs
	end if
	if lastUsedMode is equal to "64-bit mode" then
		--application will run in 64-bit mode
		do shell script "arch -arch x86_64 /Applications/ &> /dev/null &"
		--application will run in 32-bit mode
		do shell script "arch -arch i386 /Applications/ &> /dev/null &"
	end if
	--we don't need to ask the user if he wants to run in 64-bit because the machine doesn't support it
	--application will run in 32-bit mode even without arch
	do shell script "/Applications/ &> /dev/null &"
end if

on kernelCanRunIn64BitMode()
		return ((do shell script "sysctl -n hw.optional.x86_64") as integer) as boolean
	on error
		return false
	end try
end kernelCanRunIn64BitMode

I’m sorry to have taken so long to reply - I had to be away from my computer for two days.

Thanks for suggesting the arch command, which I think accomplishes exactly what I need. I am very grateful for your help!