Solved

Batch command to determine the Office version installed

Posted on 2016-10-18
2
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…

740 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