Reputation: 23
Good day.
I'm trying to write a batch file that pulls general system information and writes them to a .txt file at the end for convenience later on. Thus far I've written the batch file to pull several details, but I'm stuck on the part of determining the Office version installed. I've found a thread from 3 years ago -( quick command or batch script to determine Windows and Office version )- that details the command necessary to get the version number, but I have no idea how to incorporate it as I'm still quite the learner when it comes to scripting. I can add the command suggested in that link quite easily, but it doesn't give me the output I would really like to see. when using that command, I get an answer
HKEY_CLASSES_ROOT\Word.Application\CurVer
(Default) REG_SZ Word.Application.15
Because it detects it as Word.Application.15, that means its Office 2013.
What i'm trying to achieve here is that if the answer is Word.Application.15 it should set a variable called "officeversion" as Office 2013. If its Word.Application.16 it should be Office 2016 respectively and set that as the variable called "officeversion".
For convenience, here is the version chart.
Office 97 - 7.0
Office 98 - 8.0
Office 2000 - 9.0
Office XP - 10.0
Office 2003 - 11.0
Office 2007 - 12.0
Office 2010 - 14.0
Office 2013 - 15.0
Office 2016 - 16.0
If anyone could help, it would be greatly appreciated.
Upvotes: 2
Views: 2643
Reputation: 38604
Here's something I wrote once which may help, I have never had Office products installed so it is untested:
@Echo Off & SetLocal
Echo=%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%|Find "64">Nul&&(
Set "KEY=\Wow6432Node" & Set "MWB=64")||(Set "MWB=32" & Set "MOB=32")
Set "KEY=HKLM\Software%KEY%\Microsoft\Windows\CurrentVersion\Uninstall"
Set "GUID="
For /f "Delims=" %%a In ('Reg Query %KEY% /k /f "*-001B-*0FF1CE}"') Do (
If Not Defined GUID Set "GUID=%%~nxa")
If %GUID:~-1% NEq } Set "GUID="
If Not Defined GUID (Echo= Unable to find Office Product & GoTo :EndIt)
If %GUID:~4,1% Equ 4 Set "IOV=10" Else (If %GUID:~4,1% Equ 2 (Set "IOV=07"
If Not Defined MOB Set "MOB=32") Else (If %GUID:~4,1% Equ 5 (Set "IOV=13"
) Else (If %GUID:~4,1% Equ 6 Set "IOV=16")))
If Not Defined IOV (Echo= Unknown Office version on your %MWB%-bit OS
GoTo :EndIt)
If %GUID:~20,1% NEq 1 Set "MOB=32"
If Not Defined MOB Set "MOB=64"
Echo=&Echo= Office 20%IOV% %MOB%-bit Product installed on a %MWB%-bit OS
:EndIt
Timeout 5 1>Nul
Upvotes: 1