Solved

Batch command to determine the Office version installed

Posted on 2016-10-18
2
133 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 83

Accepted Solution

by:
oBdA earned 500 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

0
 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

778 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