How do you know those segments will always be correct?
Well batch wise I found a more dependable way for office versions, just the 32/64 bit thing for office I haven't figured out yet (just for the sake of doing it in batch, kix is easier off course).
 Code:
@ECHO OFF
FOR /F "tokens=3*" %%A IN ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe" /v Path') DO SET answer=%%A %%B
echo %answer% | findstr Office11
if errorlevel 1 (
    GOTO :12
) ELSE (
    GOTO :office11
)
:12
echo %answer% | findstr Office12
if errorlevel 1 (
    GOTO :13
) ELSE (
    GOTO :office12
)
:13
echo %answer% | findstr Office13
if errorlevel 1 (
    GOTO :14
) ELSE (
    GOTO :office13
)
:14
echo %answer% | findstr Office14
if errorlevel 1 (
    GOTO :END
) ELSE (
    GOTO :office14
)
:Office11
MSG * Found Office 2003
GOTO :END

:Office12
MSG * Found Office 2007
GOTO :END

:Office13
MSG * Found Office 2010
GOTO :END

:Office14
MSG * Found Office 2013
GOTO :END

:END
pause