Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Batch command to determine the Office version installed

Posted on 2016-10-18
2
Medium Priority
?
2,378 Views
Last Modified: 2016-10-18
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 -( http://stackoverflow.com/questions/18820434/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.
0
Comment
Question by:Ryno van Zyl
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 41848134
Try this (the first two lines should be at the very beginning of the script; the rest can be anywhere):
@echo off
setlocal enabledelayedexpansion

set Office[7]=Office 97
set Office[8]=Office 98
set Office[9]=Office 2000
set Office[10]=Office XP
set Office[11]=Office 2003
set Office[12]=Office 2007
set Office[14]=Office 2010
set Office[15]=Office 2013
set Office[16]=Office 2016
set CurVer=
for /f "tokens=3 delims=." %%a in ('reg.exe query "HKCR\Word.Application\CurVer" /ve ^| find.exe /i "(Default)"') do set CurVer=%%a
if defined CurVer (
	set OfficeVersion=!Office[%CurVer%]!
	echo Found Office: Version %CurVer%, '!OfficeVersion!'
) else (
	echo No Office installation found.
)

Open in new window

1
 

Author Closing Comment

by:Ryno van Zyl
ID: 41848147
I don't know how that works, or why it works, but it works beautifully! It's been 10min since I asked, and I'm already moving forward. I LOVE THIS SITE! A huge thank you to you 0BdA!

As a side note, oBdA, would you mind if I sent you my script to glance at and give an opinion on it perhaps?
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
New style of hardware planning for Microsoft Exchange server.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question