Batch file check office architecture version

2019-02-28 09:29发布

问题:

i have the following script, that will print the current version of office and the architecture of the OS,

   Echo off&SetLocal
Set "KEY="&Set "GUID="&Set "IOV="&Set "MWB=32"&Set "MOB=32"
Echo=%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%|Find "64">Nul&&(
   Set "KEY=\Wow6432Node"&Set "MWB=64")
Set "KEY=HKLM\Software%KEY%\Microsoft\Windows\CurrentVersion\Uninstall"
For /f "Delims=" %%a In ('Reg Query %KEY% /k /f "*-001B-*0FF1CE}"') Do (
   If Not Defined GUID Set "GUID=%%~nxa")
If Not Defined GUID (Echo=Unable to find Office Product&GoTo :EndIt)
If %GUID:~20,1% Equ 1 Set "MOB=64"
If %GUID:~4,1% Equ 4 (Set IOV=10) Else (If %GUID:~4,1% Equ 2 (Set IOV=07) Else (
      If %GUID:~4,1% Equ 5 (Set IOV=13) Else (Set IOV=??)))
Echo=&Echo= Office 20%IOV% %MOB%-bit Product installed on a %MWB%-bit OS
:EndIt

i would like to customize this script to to make some other stuff if the output is like this Office 20?? 32-bit Product installed on a 64-bit OS

   If Echo= Office 2007 32-bit Product installed on a 64-bit OS (run another script or command)

Can somebody help me implement this? Thanks in advance.

回答1:

Found the solution my self, IF %MOB%==32 IF %MWB%==64 (Echo commands)