Solved

Batch command to determine the Office version installed

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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 …
This article will show you how to use shortcut menus in the Access run-time environment.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now