Solved

Batch command to determine the Office version installed

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

751 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