使用批处理文件获取 MS 访问的补丁级别内部版本号

Using Batch files to get the patch level build number for MS access

最近的 Microsoft Office 更新破坏了许多 MS 访问程序。要解决此问题,我们必须还原客户端计算机上的更新。为了自动执行此操作,我尝试编写一个批处理文件来执行此操作,因为还原 Office 365 更新可能很困难,但不同的构建具有不同的更新,它们需要还原到。要找出它需要设置到哪个版本,我需要找出 patch/update 级别 version/build 编号。我查看了注册表但无济于事。 有没有办法获得完整的内部版本号?即:16.0.xxxx.xxxx

以下是安装了 Office 2007 的 windows7(64 位)旧 PC 的示例。

只需要改变你办公室的路径,然后执行即可。

@echo off
Mode 75,3 & color 9E
Title Get File Version of any Application from file list using WMIC by Hackoo
::******************************************************************************
REM Just Change this Variable in your case and the script will do the rest (-_°)
Set "RootFolder=C:\Program Files (x86)\Microsoft Office\Office12"
::******************************************************************************
:Main
@for %%a in ("%RootFolder%") do set "FolderName=%%~na"
Set "File_Version_List=%~dp0%FolderName%_File_Version_List.txt"
Set "ErrorFile=%~dp0%FolderName%_Error.txt
Set Extensions="*.exe"
If exist "%ErrorFile%" Del "%ErrorFile%"
If exist "%File_Version_List%" Del "%File_Version_List%"
echo(
echo          Please wait a while ... Process to get file version ...
set "BuildLineWith=call :BuildLine "
setlocal enabledelayedexpansion
CD /D "%RootFolder%"
@for /f "delims=" %%F in ('Dir /b /s %Extensions%') do (
    set "Version="
    Call :Get_AppName "%%F" AppName
    Call :Add_backSlash "%%F"
    Call :GetVersion !Application! Version
    Call :Remove_backSlash !Application!
    If defined Version (
        (
            echo !Application!
            echo !AppName! ==^> !Version!
            %BuildLineWith%*
        )>> "%File_Version_List%"
    ) else (
        (
            echo Version is not defined in !Application!
            %BuildLineWith%#
        )>> "%ErrorFile%"
    )
)
If Exist "%ErrorFile%" Start "" "%ErrorFile%"
If Exist "%File_Version_List%" Start "" /MAX "%File_Version_List%" & Exit
::*******************************************************************
:GetVersion <ApplicationPath> <Version>
Rem The argument %~1 represent the full path of the application
Rem without the double quotes
Rem The argument %2 represent the variable to be set (in our case %2=Version)
FOR /F "tokens=2 delims==" %%I IN (
  'wmic datafile where "name='%~1'" get version /format:Textvaluelist 2^>^nul'
) DO FOR /F "delims=" %%A IN ("%%I") DO SET "%2=%%A"
Exit /b
::*******************************************************************
:Add_backSlash <String>
Rem Subroutine to replace the simple "\" by a double "\" into a String
Set "Application=%1"
Set "String=\"
Set "NewString=\"
Call Set "Application=%%Application:%String%=%NewString%%%"
Exit /b
::*******************************************************************
:Remove_backSlash <String>
Rem Subroutine to replace the double "\" by a simple "\" into a String
Set "Application=%1"
Set "String=\"
Set "NewString=\"
Call Set "Application=%%Application:%String%=%NewString%%%"
Exit /b
::*******************************************************************
:Get_AppName <FullPath> <AppName>
Rem %1 = FullPath
Rem %2 = AppName
for %%i in (%1) do set "%2=%%~nxi"
exit /b
::*******************************************************************
:BuildLine
REM Thanks to ImDeepWithWindows for this nice trick of BuildLine
set "LineChar=%1"
if "%LineChar%"=="" set "LineChar=_"
for /f "tokens=2 skip=4" %%A in ('mode con: /status') do set "WindowColumns=%%A" & goto :GotColumnCount
:GotColumnCount
set "CharLine="
setlocal EnableDelayedExpansion
for /L %%A in (1,1,%WindowColumns%) do set "CharLine=!CharLine!!LineChar:~0,1!"
setlocal DisableDelayedExpansion
endlocal
echo %CharLine%
goto :eof
::*******************************************************************

所以,我得到了这样的结果:

"C:\Program Files (x86)\Microsoft Office\Office12\ACCICONS.EXE"
ACCICONS.EXE ==> 12.0.6697.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\CLVIEW.EXE"
CLVIEW.EXE ==> 12.0.6606.1000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\CNFNOT32.EXE"
CNFNOT32.EXE ==> 12.0.6776.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\DSSM.EXE"
DSSM.EXE ==> 12.0.6606.1000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"
EXCEL.EXE ==> 12.0.6787.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\excelcnv.exe"
excelcnv.exe ==> 12.0.6787.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\GRAPH.EXE"
GRAPH.EXE ==> 12.0.6658.5004
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\INFOPATH.EXE"
INFOPATH.EXE ==> 12.0.6735.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\MSACCESS.EXE"
MSACCESS.EXE ==> 12.0.6735.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\MSOHTMED.EXE"
MSOHTMED.EXE ==> 12.0.6500.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\MSPUB.EXE"
MSPUB.EXE ==> 12.0.6780.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\MSQRY32.EXE"
MSQRY32.EXE ==> 12.0.6606.1000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\MSTORDB.EXE"
MSTORDB.EXE ==> 12.0.6713.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\MSTORE.EXE"
MSTORE.EXE ==> 12.0.6713.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\OIS.EXE"
OIS.EXE ==> 12.0.6606.1000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE"
OUTLOOK.EXE ==> 12.0.6785.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\POWERPNT.EXE"
POWERPNT.EXE ==> 12.0.6775.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\PPTVIEW.EXE"
PPTVIEW.EXE ==> 12.0.6654.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\REGFORM.EXE"
REGFORM.EXE ==> 12.0.6650.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\SCANOST.EXE"
SCANOST.EXE ==> 12.0.6650.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\SCANPST.EXE"
SCANPST.EXE ==> 12.0.6650.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\SELFCERT.EXE"
SELFCERT.EXE ==> 12.0.6606.1000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\SETLANG.EXE"
SETLANG.EXE ==> 12.0.6606.1000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\VPREVIEW.EXE"
VPREVIEW.EXE ==> 12.0.6600.1000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE"
WINWORD.EXE ==> 12.0.6787.5000
***************************************************************************
"C:\Program Files (x86)\Microsoft Office\Office12\Wordconv.exe"
Wordconv.exe ==> 12.0.6500.5000
***************************************************************************