0

I'm asking what the best method to know if the office is installed or not on windows in batch?

So, i create this batch file to know which word version is installed !

My Question : Is there any method else in batch that you know to find out if office is installed on Windows and which version ?


@echo off
Title Check if Word Office is installed or Not ? And Which Version Number ?
@for /f "skip=2 tokens=3 delims=." %%a in (
    'reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer" /f App*'
) do (
    Set "VerNumber=%%a.0"
)
SetLocal EnableDelayedExpansion
If defined VerNumber (
    If [!VerNumber!] EQU [11.0] (Set "MSOffice=Office 2003")
    If [!VerNumber!] EQU [12.0] (Set "MSOffice=Office 2007")
    If [!VerNumber!] EQU [14.0] (Set "MSOffice=Office 2010")
    If [!VerNumber!] EQU [15.0] (Set "MSOffice=Office 2013")
    If [!VerNumber!] EQU [16.0] (Set "MSOffice=Office 2016+")
    Color 0B & echo Word Application is installed ("!MSOffice!"^) (VerNumber="!VerNumber!"^)
) else ( 
    Color 0C & echo Word Application is not installed ! & Timeout /T 3 /Nobreak>nul & Exit /B
)
EndLocal
Pause & Exit /B
2

1 Answer 1

2

The questions linked in the comment only answer for version of Office when installed but don't really try to answer when there is no version installed

In my test, your variable is always set even when you don't have Office installed....

Add in your For /f loop the 2>nul redirector and your loop will not return any string that defines your variable...

Your if defined are not working....

@echo off
Title Check if Word Office is installed or Not ? And Which Version Number ?
@for /f "skip=2 tokens=3 delims=." %%a in (
    '2^>nul reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer" /f App*'
) do (
    Set "VerNumber=%%a.0"
)
SetLocal EnableDelayedExpansion
If defined VerNumber (
    If [!VerNumber!] EQU [11.0] (Set "MSOffice=Office 2003")
    If [!VerNumber!] EQU [12.0] (Set "MSOffice=Office 2007")
    If [!VerNumber!] EQU [14.0] (Set "MSOffice=Office 2010")
    If [!VerNumber!] EQU [15.0] (Set "MSOffice=Office 2013")
    If [!VerNumber!] EQU [16.0] (Set "MSOffice=Office 2016+")
    Color 0B & echo Word Application is installed ("!MSOffice!"^) (VerNumber="!VerNumber!"^)
) else ( 
    Color 0C & Timeout /T 3 /Nobreak | echo Word Application is not installed^^! & Exit /B
)
EndLocal
Pause & Exit /B

1
  • hi, see, this echo;from here && (line 50 ) is from my debug/test (i do not have any recent itens/files opened by/in powerpoint, so, one error came from/because my empty recent list..., also line 3 for to see the full screen results in test.. Mode 300,500.... it this, so sorry my limited english/hop you get the msg.. i forgot to remove/revert my test/edit..
    – Io-oI
    Commented Jun 17, 2022 at 1:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .