[SOLVED] batch to check for mutiple conditions of Office?
Posted: 16 Feb 2014 18:52
I know the if/else statement will only check one condition which works fine if running a 32-bit OS (because it only has the Program Files directory) but when checking on a 64-bit OS that contains both Program Files and Program Files (x86) I cannot get the output I need.
Update [SOLVED]: See code snippet
After poking around in the registry I discovered that Office adds a bitness value of either x64 or x86 so then
it was just a simple matter of adding a reg query script for a 64-bit OS. Maybe this may be useful for someone else.
Now life is good again!..DP
Update [SOLVED]: See code snippet
After poking around in the registry I discovered that Office adds a bitness value of either x64 or x86 so then
it was just a simple matter of adding a reg query script for a 64-bit OS. Maybe this may be useful for someone else.
Now life is good again!..DP
Code: Select all
@echo off
:: Office_2010-2013.cmd for Windows 7 x64 or x86
:: ### OSBitCheck
if exist "%systemroot%\syswow64\cmd.exe" (call :OSx64) else (call :OSx86)
:: SECTION FOR 32-BIT OS
:OSx86
:: ### Checking for Office Version on 32-bit OS
if exist "%programfiles%\Microsoft Office\Office14\winword.exe" (call :2010) else (call :2013)
:2013
echo Running Office 2013 32-bit with a 32-bit OS.. && timeout /t 5 >nul
::< code >
exit
:2010
echo Running Office 2010 32-bit with a 32-bit OS.. && timeout /t 5 >nul
::< code >
exit
:: SECTION FOR 64-BIT OS
:OSx64
:: ### Query Registry For Installed Office Bit/Version
reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Outlook" /v Bitness | findstr x64>nul
if '%errorlevel%' EQU '0' goto:Off64_10
cls
reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Outlook" /v Bitness | findstr x64>nul
if '%errorlevel%' EQU '0' goto:Off64_13
cls
reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Outlook" /v Bitness | findstr x86>nul
if '%errorlevel%' EQU '0' goto:Off32_10
cls
reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Outlook" /v Bitness | findstr x86>nul
if '%errorlevel%' EQU '0' goto:Off32_13
cls