[Solved] batch file code to detect 32-bit vs 64-bit office not working [closed]


If you’re wanting to check the bitness, version and install location of Microsoft Office, you could give this script a test to see if it works for you any better:

@Echo Off
If Defined PROCESSOR_ARCHITEW6432 (
    Start "" /D "%__CD__%" "%SystemRoot%\SysNative\cmd.exe" /C "%~f0"&Exit /B)
Set /A "OSA=MWB=%PROCESSOR_ARCHITECTURE:~-2%"
If %OSA%==86 Set "MWB=32"
Set "MOB="&Set "GUID="&Set "REG=%__AppDir__%reg.exe"
Call :Chk
If Not Defined MOB If %MWB%==64 Call :Chk \Wow6432Node
If Not Defined MOB (Echo Microsoft Office product not installed&GoTo :EndIt
)Else If Not Defined IOV (Echo Unable to determine Microsoft Office version
    GoTo :EndIt)
Echo %MWB%-bit OS with an Office 20%IOV% %MOB%-bit product installed in %OIL%
:EndIt
>Nul Timeout -1
GoTo :EOF

:Chk
Set "MOB="&Set "GUID="&Set "OIL="
Set "Key=HKLM\Software%1\Microsoft\Windows\CurrentVersion\Uninstall"
For /F Delims^= %%A In ('""%REG%" Query "%Key%" /K /F "*-001B-*0FF1CE}""'
)Do Set "GUID=%%~nxA"&GoTo :Next
:Next
If Not "%GUID:~-1%"=="}" Set "GUID="
If Not Defined GUID Exit /B
Set "MOB=32"&If "%GUID:~20,1%"=="1" Set "MOB=64"
If "%GUID:~4,1%"=="2" Set "IOV=07"
If "%GUID:~4,1%"=="4" Set "IOV=10"
If "%GUID:~4,1%"=="5" Set "IOV=13"
If "%GUID:~4,1%"=="6" Set "IOV=16"
If Not Defined IOV Exit /B
For /F Tokens^=2* %%A In ('""%REG%" Query "%Key%\%GUID%" /V "InstallLocation""'
)Do Set "OIL=%%B"
Exit /B

Please note however, that this script was designed to work with Windows Microsoft Office products from versions 2007 up to 2016 inclusive. The script only checks for a specific uninstall key for Microsoft Word, (it is assumed that only in very rare cases would somebody install Office without including the Word product), and there is no guarantee that all versions will use the same uninstall key.

I will not be modifying this code for any additions/changes to your question, or providing help on modifications for purposes other than those for which it was intended.

2

solved batch file code to detect 32-bit vs 64-bit office not working [closed]