Now that Office also comes in a 64bit install, where in the registry do you find out if the version of Office installed is 32bit or 64bit?
Now that Office also comes in a 64bit install, where in the registry do you find out if the version of Office installed is 32bit or 64bit?
From TechNet article on 64-bit editions of Office 2010:
If you have installed Office 2010 including Microsoft Outlook 2010, Outlook sets a registry key named Bitness of type REG_SZ on the computer on which it is installed. The Bitness registry key indicates whether the Outlook 2010 installation is 32-bit or 64-bit. This may be useful to administrators who are interested in auditing computers to determine the installed versions of Office 2010 in their organization.
- Registry path: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\14.0\Outlook
- if you have installed Office 2013 then use this Registry path: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\15.0\Outlook
- Registry key: Bitness
- Value: either x86 or x64
and elsewhere in the same article:
Starting with Office 2010, Outlook is available as a 32-bit application and a 64-bit application. The version (bitness) of Outlook that you choose depends on the edition of the Windows operating system (32-bit or 64-bit) and the edition of Office 2010 (32- or 64-bit) that is installed on the computer, if Office is already installed on that computer.
Factors that determine the feasibility of installing a 32-bit or a 64-bit version of Outlook include the following:
- You can install 32-bit Office 2010 and 32-bit Microsoft Outlook 2010 on a supported 32-bit or 64-bit edition of the Windows operating system. You can install the 64-bit version of Office 2010 and 64-bit Outlook 2010 only on a supported 64-bit operating system.
- The default installation of Office 2010 on a 64-bit edition of the Windows operating system is 32-bit Office 2010.
- The bitness of an installed version of Outlook is always the same as the bitness of Office 2010, if Office is installed on the same computer. That is, a 32-bit version of Outlook 2010 cannot be installed on the same computer on which 64-bit versions of other Office 2010 applications are already installed, such as 64-bit Microsoft Word 2010 or 64-bit Microsoft Excel 2010. Similarly, a 64-bit version of Outlook 2010 cannot be installed on the same computer on which 32-bit versions of other Office applications are already installed.
I found this approach:
If HKLM\Software\WOW6432Node exists then Windows is 64-bit.
If HKLM\Software\WOW6432Node\Microsoft\Office exists, then Office is 32-bit.
If HKLM\Software\WOW6432Node\Microsoft\Office does not exist, but HKLM\Software\Microsoft\Office does exist, then Office is 64-bit.
If HKLM\Software\WOW6432Node does not exist, then Windows and Office are 32-bit.
Source: Technet Forums
EDIT : Solution without touching RegistryKeys - im Sorry Op.
I found out that there is a solution in C# - the original can be found here : https://blogs.msdn.microsoft.com/webdav_101/2016/07/26/sample-detecting-installed-outlook-and-its-bitness/
I modified it a bit for my needs.
just pass the correct outlookPath to GetOutlookBitness()
public enum BinaryType : uint
{
SCS_32BIT_BINARY = 0, // A 32-bit Windows-based application
SCS_64BIT_BINARY = 6, // A 64-bit Windows-based application.
SCS_DOS_BINARY = 1, // An MS-DOS – based application
SCS_OS216_BINARY = 5, // A 16-bit OS/2-based application
SCS_PIF_BINARY = 3, // A PIF file that executes an MS-DOS – based application
SCS_POSIX_BINARY = 4, // A POSIX – based application
SCS_WOW_BINARY = 2 // A 16-bit Windows-based application
}
[DllImport("kernel32.dll")]
static extern bool GetBinaryType(string lpApplicationName, out BinaryType lpBinaryType);
public int GetOutlookBitness(string FilePath)
{
int bitness = 0;
if (File.Exists(FilePath))
{
BinaryType type;
GetBinaryType(FilePath, out type);
switch (type)
{
case BinaryType.SCS_32BIT_BINARY:
bitness = 32;
break;
case BinaryType.SCS_64BIT_BINARY:
bitness = 64;
break;
}
}
return bitness;
}
In my tests many of the approaches described here fail, I think because they rely on entries in the Windows registry that turn out to be not reliably present, depending on Office version, how it was installed etc. So a different approach is to not use the registry at all (Ok, so strictly that makes it not an answer to the question as posed), but instead write a script that:
Here's that approach implemented in VBScript:
Function OfficeBitness()
Dim VBACode, Excel, Wb, Module, Result
VBACode = "Function Is64bit() As Boolean" & vbCrLf & _
"#If Win64 Then" & vbCrLf & _
" Is64bit = True" & vbCrLf & _
"#End If" & vbCrLf & _
"End Function"
On Error Resume Next
Set Excel = CreateObject("Excel.Application")
Excel.Visible = False
Set Wb = Excel.Workbooks.Add
Set Module = Wb.VBProject.VBComponents.Add(1)
Module.CodeModule.AddFromString VBACode
Result = Excel.Run("Is64bit")
Set Module = Nothing
Wb.Saved = True
Wb.Close False
Excel.Quit
Set Excel = Nothing
On Error GoTo 0
If IsEmpty(Result) Then
OfficeBitness = 0 'Alternatively raise an error here?
ElseIf Result = True Then
OfficeBitness = 64
Else
OfficeBitness = 32
End If
End Function
PS. This approach runs more slowly than others here (about 2 seconds on my PC) but it might turn out to be more reliable across different installations and Office versions.
After some months, I've realised there may be a simpler approach, though still one that instantiates an Excel instance. The VBScript is:
Function OfficeBitness()
Dim Excel
Set Excel = CreateObject("Excel.Application")
Excel.Visible = False
If InStr(Excel.OperatingSystem,"64") > 0 Then
OfficeBitness = 64
Else
OfficeBitness = 32
End if
Excel.Quit
Set Excel = Nothing
End Function
This relies on the fact that Application.OperatingSystem, when called from 32-bit Excel on 64-bit Windows returns Windows (32-bit) NT 10.00 or at least it does on my PC. But that's not mentioned in the docs.
This Wikipedia article states:
On 64-bit versions of Windows, there are two folders for application files; the
"Program Files"folder contains 64-bit programs, and the"Program Files (x86)"folder contains 32-bit programs.
So if the program is installed under C:\Program Files it is a 64-bit version. If it is installed under C:\Program Files (x86) it is a 32-bit installation.