How to Detect Microsoft Office Version Name
Programmatically, what method can get the name of the installed Microsoft Office version? I have tried every Powershell command, VBScript, and WMI query I could find. I have pored through the registry and the file system, and I can find no perfect method for collecting the installed Office version.
The closest method I was able to come up with was using a WMIC query:
wmic product where "Name like '%Office%'" get name, version
Unfortunately, this returns a varying array of applications, and even if more finely filtered, it doesn't tell me if "Office 16" is "Pro", "Professional Plus", or "Office365".
Otherwise, the registry value at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Scenario\INSTALL\ProductstoAdd
It exists at least on version 2016, but not with older versions. And it, itself, doesn't contain a friendly name, so further scripting would be necessary to convert data of ProPlusRetail.16_en-us_x-none
to "Office 2016 Professional Plus" or O365BusinessRetail.16_en-us_x-none
to "Office 365 Business (2016)"
I'm hoping that someone has an easier methodology than many if/else if/else if statements in a huge script.
You can find a name of installed Microsoft Office in registry. The process may be automated following the steps:
Check the registry keys
for 32-bit versions:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
for 64-bit versions:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
If a key matches one of the Product ID patterns, as per Description of the numbering scheme for product code GUIDs in Office 2016, 2013, 2010, 2007, 2003, XP, 2000, then read DisplayName
Key Value, which is actually the name of installed Office.
Also I found Robust Office Inventory Scan Tool (ROISCAN), that performs quite full search for installed Microsoft Office versions.
Try this:
setlocal enableDelayedExpansion
for /f "tokens=2 delims==" %%O in ('ftype ^|findstr /r /I "\\OFFICE[0-9]*" 2^>nul') do (
set "verp=%%~O"
goto :end_for
)
:end_for
for %%P in (%verp%) do (
set "off_path=%%~dpP"
for %%V in ("!off_path:~0,-1!") do (
set "office_version=%%~nV"
goto :end_for2
)
)
:end_for2
if [%office_version%] == [] echo No Office installed & goto end
echo %office_version%
:end
endlocal
As a possible option try this Poswershell query:
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\O365ProPlusRetail* | Select-Object DisplayName, DisplayVersion, Publisher